이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
long long n, ans;
char grid[500005][2][2];
map<vector<char>, int> up, lt, rt, dn, lu, ur, rd, dl, all;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i=0; i<n; i++){
for(int j=0; j<2; j++){
for(int k=0; k<2; k++){
cin >> grid[i][j][k];
}
}
}
ans=0;
for(int i=0; i<n; i++){
char a=grid[i][0][0], b=grid[i][0][1], c=grid[i][1][0], d=grid[i][1][1];
ans+=up[{c, d}]+rt[{a, c}]+dn[{a, b}]+lt[{b, d}];
ans-=all[{c, d, a, b}]+all[{b, a, d, c}];
if(a==d) ans-=ur[{c, a, c}]+dl[{b, a, b}];
if(b==c) ans-=lu[{d, b, d}]+rd[{a, b, a}];
if(a==d && b==c) ans+=3*all[{b, a, a, b}];
up[{a, b}]++;
rt[{b, d}]++;
dn[{c, d}]++;
lt[{a, c}]++;
lu[{c, a, b}]++;
ur[{a, b, d}]++;
rd[{b, d, c}]++;
dl[{d, c, a}]++;
all[{a, b, c, d}]++;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |