Submission #1690196
Source Code Expand
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// _oo0oo_ //
// o8888888o //
// 88" . "88 ------ hzt1 //
// (| -_- |) //
// 0\ = /0 //
// ___/`---'\___ //
// .' \| |// '. //
// / \||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \ - /// | | //
// | \_| ''\---/'' |_/ | //
// \ .-\__ '-' ___/-. / //
// ___'. .' /--.--\ `. .'___ //
// ."" '< `.___\_<|>_/___.' >' "". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `_. \_ __\ /__ _/ .-` / / //
// =====`-.____`.___ \_____/___.-`___.-'===== //
// `=---=' //
// //
// //
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// //
// God-He Bless All. //
// This Code Will Never Explode. //
// //
// //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<map>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
if(head==tail) {
int l=fread(buffer,1,Size,stdin);
tail=(head=buffer)+l;
}
if(head==tail) return -1;
return *head++;
}
inline int read() {
int x=0,f=1;char c=Getchar();
for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
return x*f;
}
typedef long long ll;
const int maxn=410;
struct State {
int a,b,c,d;
bool operator < (const State& S) const {
if(a!=S.a) return a<S.a;
if(b!=S.b) return b<S.b;
if(c!=S.c) return c<S.c;
return d<S.d;
}
bool operator == (const State& S) {
return a==S.a&&b==S.b&&c==S.c&&d==S.d;
}
}A[maxn][4];
map<ll,int> M;
#define hash(a,b,c,d) (a*201525010ll+b*252501ll+c*2501+d)
void del(State x) {
M[hash(x.a,x.b,x.c,x.d)]--;
M[hash(x.b,x.c,x.d,x.a)]--;
M[hash(x.c,x.d,x.a,x.b)]--;
M[hash(x.d,x.a,x.b,x.c)]--;
}
void add(State x) {
M[hash(x.a,x.b,x.c,x.d)]++;
M[hash(x.b,x.c,x.d,x.a)]++;
M[hash(x.c,x.d,x.a,x.b)]++;
M[hash(x.d,x.a,x.b,x.c)]++;
}
int main() {
int n=read();
rep(i,1,n) {
int a=read(),b=read(),c=read(),d=read();
A[i][0]=(State){a,b,c,d};
A[i][1]=(State){b,c,d,a};
A[i][2]=(State){c,d,a,b};
A[i][3]=(State){d,a,b,c};
M[hash(a,b,c,d)]++;M[hash(b,c,d,a)]++;M[hash(c,d,a,b)]++;M[hash(d,a,b,c)]++;
}
ll ans=0;
rep(i,1,n) rep(j,i+1,n) if(i!=j) {
del(A[i][0]);del(A[j][0]);
rep(y,0,3) {
swap(A[j][y].a,A[j][y].b);swap(A[j][y].c,A[j][y].d);
State S[4];
S[0]=(State){A[i][0].b,A[i][0].a,A[j][y].a,A[j][y].b};
S[1]=(State){A[j][y].b,A[j][y].c,A[i][0].c,A[i][0].b};
S[2]=(State){A[i][0].d,A[i][0].c,A[j][y].c,A[j][y].d};
S[3]=(State){A[j][y].a,A[i][0].a,A[i][0].d,A[j][y].d};
int c1=M[hash(A[i][0].b,A[i][0].a,A[j][y].a,A[j][y].b)];del(S[0]);
int c2=M[hash(A[j][y].b,A[j][y].c,A[i][0].c,A[i][0].b)];del(S[1]);
int c3=M[hash(A[i][0].d,A[i][0].c,A[j][y].c,A[j][y].d)];del(S[2]);
int c4=M[hash(A[j][y].a,A[i][0].a,A[i][0].d,A[j][y].d)];del(S[3]);
ans+=(ll)c1*c2*c3*c4;
rep(k,0,3) add(S[k]);
swap(A[j][y].a,A[j][y].b);swap(A[j][y].c,A[j][y].d);
}
add(A[i][0]);add(A[j][0]);
}
printf("%lld\n",ans/3);
return 0;
}
Submission Info
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 |
1 ms |
256 KB |
0_001.txt |
AC |
1 ms |
256 KB |
0_002.txt |
AC |
1 ms |
256 KB |
1_003.txt |
AC |
58 ms |
256 KB |
1_004.txt |
AC |
5 ms |
256 KB |
1_005.txt |
AC |
90 ms |
256 KB |
1_006.txt |
AC |
63 ms |
256 KB |
1_007.txt |
AC |
160 ms |
256 KB |
1_008.txt |
AC |
144 ms |
256 KB |
1_009.txt |
AC |
464 ms |
256 KB |
1_010.txt |
AC |
77 ms |
256 KB |
1_011.txt |
AC |
1007 ms |
896 KB |
1_012.txt |
AC |
7 ms |
640 KB |
1_013.txt |
TLE |
4218 ms |
267904 KB |
1_014.txt |
AC |
21 ms |
3456 KB |
1_015.txt |
TLE |
4222 ms |
314240 KB |
1_016.txt |
AC |
959 ms |
88064 KB |
1_017.txt |
TLE |
4222 ms |
319488 KB |
1_018.txt |
TLE |
4222 ms |
312192 KB |
1_019.txt |
TLE |
4222 ms |
308224 KB |