Submission #1661871
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX_N = 405, base = 1013, MOD = 1000007;
typedef long long i64;
typedef unsigned long long u64;
typedef pair<int, int> pii;
int C[MAX_N][4], N;
class Hash_Table {
public:
int head[MOD], cnt, nxt[MOD], num[MOD];
u64 key[MOD];
void add(pair<pii, pii> x, int v) {
u64 val = (u64)x.first.first * base + (u64)x.first.second * base * base;
val += (u64)x.second.first * base * base * base;
val += (u64)x.second.second * base * base * base * base;
int temp = val % MOD;
for (int i = head[temp]; i; i = nxt[i])
if (key[i] == val) {
num[i] += v;
return;
}
nxt[++cnt] = head[temp], head[temp] = cnt, num[cnt] = v, key[cnt] = val;
}
int query(pair<pii, pii> x) {
u64 val = (u64)x.first.first * base + (u64)x.first.second * base * base;
val += (u64)x.second.first * base * base * base;
val += (u64)x.second.second * base * base * base * base;
int temp = val % MOD;
for (int i = head[temp]; i; i = nxt[i])
if (key[i] == val) return num[i];
return 0;
}
} cnt;
void insert(int col[4]) {
static int t[4];
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) t[j] = col[(j + i) % 4];
cnt.add(make_pair(make_pair(t[0], t[1]), make_pair(t[2], t[3])), 1);
}
}
void substract(int col[4]) {
static int t[4];
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) t[j] = col[(j + i) % 4];
cnt.add(make_pair(make_pair(t[0], t[1]), make_pair(t[2], t[3])), -1);
}
}
int main() {
scanf("%d", &N);
for (int i = 1; i <= N; ++i)
for (int j = 0; j < 4; ++j)
scanf("%d", &C[i][j]);
i64 res = 0;
for (int i = 1; i <= N; ++i) {
for (int j = 1; j < i; ++j) {
substract(C[j]);
for (int d = 0; d < 4; ++d) {
static int t[4], A[4];
i64 num = 1;
for (int k = 0; k < 4; ++k) t[k] = C[j][((k + d) % 4) ^ 1];
for (int k = 0; k < 4; ++k) {
A[0] = C[i][(k + 1) % 4], A[1] = C[i][k];
A[3] = t[(k + 1) % 4], A[2] = t[k];
num *= cnt.query(make_pair(make_pair(A[0], A[1]), make_pair(A[2], A[3])));
substract(A);
}
for (int k = 0; k < 4; ++k) {
A[0] = C[i][(k + 1) % 4], A[1] = C[i][k];
A[3] = t[(k + 1) % 4], A[2] = t[k];
insert(A);
}
res += num;
}
insert(C[j]);
}
insert(C[i]);
}
printf("%lld\n", res);
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:59:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
./Main.cpp:62:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &C[i][j]);
^
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 |
2 ms |
7424 KB |
0_001.txt |
AC |
1 ms |
6400 KB |
0_002.txt |
AC |
2 ms |
6272 KB |
1_003.txt |
AC |
99 ms |
6272 KB |
1_004.txt |
AC |
8 ms |
6272 KB |
1_005.txt |
AC |
100 ms |
6400 KB |
1_006.txt |
AC |
72 ms |
6400 KB |
1_007.txt |
AC |
100 ms |
6528 KB |
1_008.txt |
AC |
88 ms |
6528 KB |
1_009.txt |
AC |
101 ms |
7040 KB |
1_010.txt |
AC |
17 ms |
7040 KB |
1_011.txt |
AC |
109 ms |
8320 KB |
1_012.txt |
AC |
4 ms |
8320 KB |
1_013.txt |
RE |
296 ms |
19712 KB |
1_014.txt |
AC |
5 ms |
10368 KB |
1_015.txt |
RE |
141 ms |
19712 KB |
1_016.txt |
RE |
138 ms |
19712 KB |
1_017.txt |
RE |
137 ms |
19712 KB |
1_018.txt |
RE |
137 ms |
19712 KB |
1_019.txt |
RE |
137 ms |
19712 KB |