Submission #1675294
Source Code Expand
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;
typedef long long LL;
typedef pair <int, int> pii;
inline int Read()
{
int x = 0, f = 1, c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-')
f = -1;
for (; isdigit(c); c = getchar())
x = x * 10 + c - '0';
return x * f;
}
const int MAXN = 405;
LL ans, ways, f[MAXN], tmp[4];
map <LL, int> cnt;
int n, a[MAXN][4];
inline LL Get(int a, int b, int c, int d)
{
int e[4] = {a, b, c, d};
LL ret = 1LL << 60;
for (int i = 0; i < 4; i ++)
{
LL cur = 0;
for (int j = 0; j < 4; j ++)
cur = cur << 10 | e[i + j & 3];
ret = min(ret, cur);
}
return ret;
}
inline int Get(LL x)
{
if (x >> 20 == (x & (1 << 20) - 1))
{
if (x >> 30 == (x & (1 << 10) - 1))
return 4;
return 2;
}
return 1;
}
int main()
{
#ifdef wxh010910
freopen("data.in", "r", stdin);
#endif
n = Read();
for (int i = 1; i <= n; i ++)
{
for (int j = 0; j < 4; j ++)
a[i][j] = Read();
cnt[f[i] = Get(a[i][0], a[i][1], a[i][2], a[i][3])] ++;
}
for (int i = 1; i <= n; i ++)
{
cnt[f[i]] --;
for (int j = i + 1; j <= n; j ++)
{
cnt[f[j]] --;
for (int k = 0; k < 4; k ++)
{
ways = 1;
for (int l = 0; l < 4; l ++)
{
tmp[l] = Get(a[i][l + 1 & 3], a[i][l], a[j][k - l + 5 & 3], a[j][k - l + 4 & 3]);
if (!cnt[tmp[l]])
tmp[l] = -1, ways = 0;
else
ways *= cnt[tmp[l]] * Get(tmp[l]), cnt[tmp[l]] --;
}
ans += ways;
for (int l = 0; l < 4; l ++)
if (~tmp[l])
cnt[tmp[l]] ++;
}
cnt[f[j]] ++;
}
cnt[f[i]] ++;
}
return printf("%lld\n", ans / 3), 0;
}
Submission Info
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
900 / 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 |
42 ms |
256 KB |
1_004.txt |
AC |
4 ms |
256 KB |
1_005.txt |
AC |
48 ms |
256 KB |
1_006.txt |
AC |
35 ms |
256 KB |
1_007.txt |
AC |
68 ms |
256 KB |
1_008.txt |
AC |
62 ms |
256 KB |
1_009.txt |
AC |
125 ms |
256 KB |
1_010.txt |
AC |
18 ms |
256 KB |
1_011.txt |
AC |
130 ms |
384 KB |
1_012.txt |
AC |
2 ms |
384 KB |
1_013.txt |
AC |
784 ms |
68352 KB |
1_014.txt |
AC |
4 ms |
1024 KB |
1_015.txt |
AC |
734 ms |
80000 KB |
1_016.txt |
AC |
125 ms |
22272 KB |
1_017.txt |
AC |
765 ms |
80128 KB |
1_018.txt |
AC |
773 ms |
80000 KB |
1_019.txt |
AC |
815 ms |
78976 KB |