Submission #1513831
Source Code Expand
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
const db pi = acos(-1.0);
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}
#define Node(a, b, c, d) mp(a,mp(b,mp(c,d)))
map <pair<int, pair<int, pii> >, ll> cnt;
const int N = 500;
int A[N][4];
int n, num[4];
void fz(pair<int, pair<int,pii> > t)
{
num[0] = t.X;
num[1] = t.Y.X;
num[2] = t.Y.Y.X;
num[3] = t.Y.Y.Y;
}
pair<int, pair<int,pii> > stand(pair<int, pair<int,pii> > t)
{
fz(t);
pair<int, pair<int,pii> > tmp[4];
rep(s, 0, 3)
tmp[s] = Node(num[(s + 0) % 4], num[(s + 1) % 4], num[(s + 2) % 4], num[(s + 3) % 4]);
sort(tmp, tmp + 4);
return tmp[0];
}
void update(int id,int val)
{
pair<int, pair<int,pii> > now = stand(Node(A[id][0], A[id][1], A[id][2], A[id][3]));
cnt[now] += val;
}
int cal(pair<int, pair<int,pii> > t)
{
fz(t);
pair<int, pair<int,pii> > tmp[4];
rep(s, 0, 3) tmp[s] = Node(num[(s + 0) % 4], num[(s + 1) % 4], num[(s + 2) % 4], num[(s + 3) % 4]);
int c = 0;
rep(s, 0, 3) if(tmp[s] == tmp[0]) c ++;
return c;
}
int main()
{
n = read();
rep(i, 1, n)
{
rep(j, 0, 3) A[i][j] = read();
update(i, 1);
}
ll res = 0;
rep(i, 1, n)
{
update(i, -1);
rep(j, i + 1, n)
{
update(j, -1);
int Down[4];
rep(x, 0, 3) Down[x] = A[i][x];
int Up[4];
rep(us, 0, 3)
{
rep(y, 0, 3) Up[y] = A[j][(us - y + 4) % 4];
ll now = 1;
pair<int, pair<int,pii> > X[4];
rep(k, 0, 3)
{
X[k] = stand(Node(Down[k], Up[k], Up[(k + 1) % 4], Down[(k + 1) % 4]));
ll num = cal(X[k]);
now *= num * cnt[X[k]];
cnt[X[k]] --;
}
res += now;
rep(k, 0, 3) cnt[X[k]] ++;
}
update(j, 1);
}
update(i, 1);
}
printf("%lld\n",res / 3);
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Building Cubes with AtCoDeer |
User |
lzr156 |
Language |
C++14 (GCC 5.4.1) |
Score |
900 |
Code Size |
2741 Byte |
Status |
AC |
Exec Time |
1224 ms |
Memory |
80128 KB |
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 |
122 ms |
256 KB |
1_004.txt |
AC |
10 ms |
256 KB |
1_005.txt |
AC |
141 ms |
256 KB |
1_006.txt |
AC |
97 ms |
256 KB |
1_007.txt |
AC |
162 ms |
256 KB |
1_008.txt |
AC |
145 ms |
256 KB |
1_009.txt |
AC |
230 ms |
256 KB |
1_010.txt |
AC |
36 ms |
256 KB |
1_011.txt |
AC |
415 ms |
384 KB |
1_012.txt |
AC |
4 ms |
384 KB |
1_013.txt |
AC |
1224 ms |
68352 KB |
1_014.txt |
AC |
9 ms |
1024 KB |
1_015.txt |
AC |
1151 ms |
80000 KB |
1_016.txt |
AC |
250 ms |
22144 KB |
1_017.txt |
AC |
1152 ms |
80128 KB |
1_018.txt |
AC |
1149 ms |
80000 KB |
1_019.txt |
AC |
1199 ms |
78976 KB |