Submission #2121935
Source Code Expand
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
#define fo(f) freopen(f".in","r",stdin);freopen(f".out","w",stdout);
#define gc getchar()
inline int read()
{
int x=0;char c=gc;
for(;c<48||c>57;c=gc);
for(;c>47&&c<58;c=gc)
x=(x<<1)+(x<<3)+c-48;
return x;
}
typedef long long ll;
#define maxn 405
int n;
struct data
{
int c[4];
data(int c0=0,int c1=0,int c2=0,int c3=0)
{
c[0]=c0;c[1]=c1;c[2]=c2;c[3]=c3;
}
inline friend bool operator<(data a,data b)
{
for(int i=0;i<4;++i)
if(a.c[i]^b.c[i])return a.c[i]<b.c[i];
return 0;
}
inline void rotate()
{
int t=c[0];
c[0]=c[1];c[1]=c[2];c[2]=c[3];c[3]=t;
}
inline friend bool operator==(data a,data b)
{
for(int j=0;j<4;++j)
{
int fl=1;
for(int i=0;i<4;++i)
if(a.c[i]!=b.c[(i+j)&3])
{
fl=0;
break;
}
if(fl)return true;
}
return false;
}
}sq[maxn];
map<data,int> mp;
inline void inc(data d)
{
for(int i=0;i<4;++i)
{
++mp[d];
d.rotate();
}
}
inline void dec(data d)
{
for(int i=0;i<4;++i)
{
--mp[d];
d.rotate();
}
}
inline void init()
{
fo("square");
n=read();
for(int i=1;i<=n;++i)
{
for(int j=0;j<4;++j)
sq[i].c[j]=read();
inc(sq[i]);
}
}
ll ans;
inline void calc(data l,data r,data u,data d)
{
if(!mp[l]||!mp[r]||!mp[u]||!mp[d])return;
ll a=mp[l],b,x,y;
dec(l);
b=mp[r];
dec(r);
x=mp[u];
dec(u);
y=mp[d];
inc(u);
inc(r);
inc(l);
ans+=a*b*x*y;
}
inline void solve()
{
data l,r,u,d;
for(int i=1;i<n;++i)
{
dec(sq[i]);
for(int j=i+1;j<=n;++j)
{
dec(sq[j]);
for(int k=0;k<4;++k)
{
l=data(sq[j].c[1],sq[i].c[0],sq[i].c[3],sq[j].c[2]);
r=data(sq[i].c[1],sq[j].c[0],sq[j].c[3],sq[i].c[2]);
u=data(sq[j].c[1],sq[j].c[0],sq[i].c[1],sq[i].c[0]);
d=data(sq[i].c[3],sq[i].c[2],sq[j].c[3],sq[j].c[2]);
calc(l,r,u,d);
sq[i].rotate();
}
inc(sq[j]);
}
inc(sq[i]);
}
printf("%lld\n",ans/3);
}
int main()
{
init();
solve();
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘void init()’:
./Main.cpp:6:40: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
#define fo(f) freopen(f".in","r",stdin);freopen(f".out","w",stdout);
^
./Main.cpp:75:2: note: in expansion of macro ‘fo’
fo("square");
^
./Main.cpp:6:68: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
#define fo(f) freopen(f".in","r",stdin);freopen(f".out","w",stdout);
^
./Main.cpp:75:2: note: in expansion of macro ‘fo’
fo("square");
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 900 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt, 0_002.txt |
All |
0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
TLE |
4203 ms |
256 KB |
0_001.txt |
TLE |
4203 ms |
256 KB |
0_002.txt |
TLE |
4203 ms |
256 KB |
1_003.txt |
TLE |
4203 ms |
256 KB |
1_004.txt |
TLE |
4203 ms |
256 KB |
1_005.txt |
TLE |
4203 ms |
256 KB |
1_006.txt |
TLE |
4203 ms |
256 KB |
1_007.txt |
TLE |
4203 ms |
256 KB |
1_008.txt |
TLE |
4203 ms |
256 KB |
1_009.txt |
TLE |
4203 ms |
256 KB |
1_010.txt |
TLE |
4203 ms |
256 KB |
1_011.txt |
TLE |
4203 ms |
256 KB |
1_012.txt |
TLE |
4203 ms |
256 KB |
1_013.txt |
TLE |
4203 ms |
256 KB |
1_014.txt |
TLE |
4203 ms |
256 KB |
1_015.txt |
TLE |
4203 ms |
256 KB |
1_016.txt |
TLE |
4203 ms |
256 KB |
1_017.txt |
TLE |
4203 ms |
256 KB |
1_018.txt |
TLE |
4203 ms |
256 KB |
1_019.txt |
TLE |
4203 ms |
256 KB |