Submission #1658602
Source Code Expand
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=1e5;
int gi() {
int w=0;bool q=1;char c=getchar();
while ((c<'0'||c>'9') && c!='-') c=getchar();
if (c=='-') q=0,c=getchar();
while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
return q? w:-w;
}
const int mo=1e7+9;
int head[mo],nxt[N],w[N],v[N],tot;LL to[N];
int c[N][4];
inline void ins(LL s,int t) {
int h=s%mo;
for (int i=head[h];i;i=nxt[i])
if (to[i]==s) { w[i]+=t; return; }
to[++tot]=s,nxt[tot]=head[h],head[h]=tot,w[tot]=t;
v[tot]=s%1000000==s/1000000?(s%1000==s/1000000000?4:2):1;
}
inline int find(LL s) {
for (int i=head[s%mo];i;i=nxt[i])
if (to[i]==s) return w[i]*v[i];
return 0;
}
inline LL get(int k,int t) { LL s=0; for (int i=0;i<4;i++) s=s*1000+c[k][(t+i)&3]; return s; }
inline void Add(LL s,int t) {
LL p[4];
for (int i=0;i<4;i++) p[i]=s,s=s/1000+s%1000*1000000000;
sort(p,p+4);
for (int i=0;i<4;i++) if (!i||p[i]!=p[i-1]) ins(p[i],t);
}
inline void add(int k,int t) { Add(get(k,0),t); }
int main()
{
int n=gi(),i,j,k,t;LL s,ans=0,pi;
for (i=0;i<n;add(i++,1))
for (j=0;j<4;j++)
c[i][j]=gi();
for (i=0;i<n;i++) {
add(i,-1);
for (j=i+1;j<n;j++) {
add(j,-1);
reverse(c[j],c[j]+4);
for (k=0;k<4;k++) {
pi=1;
for (t=0;t<4;t++) {
s=((c[j][(k+t)&3]*1000LL+c[j][(k+t+1)&3])*1000+c[i][(t+1)&3])*1000+c[i][t];
pi*=find(s);
Add(s,-1);
}
for (t=0;t<4;t++) {
s=((c[j][(k+t)&3]*1000LL+c[j][(k+t+1)&3])*1000+c[i][(t+1)&3])*1000+c[i][t];
Add(s,1);
}
ans+=pi;
}
reverse(c[j],c[j]+4);
add(j,1);
}
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Building Cubes with AtCoDeer |
User |
laofu |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1881 Byte |
Status |
RE |
Exec Time |
4204 ms |
Memory |
41216 KB |
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 |
AC |
4 ms |
16640 KB |
0_001.txt |
AC |
2 ms |
4352 KB |
0_002.txt |
AC |
2 ms |
2304 KB |
1_003.txt |
AC |
74 ms |
2304 KB |
1_004.txt |
AC |
7 ms |
2304 KB |
1_005.txt |
AC |
109 ms |
4352 KB |
1_006.txt |
AC |
80 ms |
4352 KB |
1_007.txt |
AC |
127 ms |
6400 KB |
1_008.txt |
AC |
112 ms |
6400 KB |
1_009.txt |
AC |
134 ms |
10496 KB |
1_010.txt |
AC |
22 ms |
10496 KB |
1_011.txt |
AC |
141 ms |
20864 KB |
1_012.txt |
AC |
6 ms |
20864 KB |
1_013.txt |
TLE |
4203 ms |
29696 KB |
1_014.txt |
AC |
9 ms |
27648 KB |
1_015.txt |
TLE |
4204 ms |
41216 KB |
1_016.txt |
RE |
117 ms |
41216 KB |
1_017.txt |
TLE |
4204 ms |
41216 KB |
1_018.txt |
TLE |
4204 ms |
41216 KB |
1_019.txt |
RE |
117 ms |
41216 KB |