Submission #786068

#TimeUsernameProblemLanguageResultExecution timeMemory
786068vjudge1Cards (LMIO19_korteles)C++17
36 / 100
1078 ms48960 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...