Submission #595522

#TimeUsernameProblemLanguageResultExecution timeMemory
595522AdamGSCards (LMIO19_korteles)C++17
100 / 100
50 ms6604 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() ll ile1[26][26][4], ile2[26][26][4], ile[26][26][26][26], ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; while(n--) { char c1, c2, c3, c4; cin >> c1 >> c2 >> c3 >> c4; int a=c1-'A', b=c2-'A', c=c4-'A', d=c3-'A'; ans+=ile1[a][b][2]+ile1[d][c][0]+ile1[a][d][1]+ile1[b][c][3]; ans-=ile[d][c][b][a]+ile[b][a][d][c]; if(a==c) ans-=ile2[a][b][0]+ile2[c][d][2]; if(b==d) ans-=ile2[b][c][1]+ile2[d][a][3]; if(a==c && b==d) ans+=3*ile[b][a][b][a]; ++ile1[a][b][0]; ++ile1[d][c][2]; ++ile1[a][d][3]; ++ile1[b][c][1]; ++ile[a][b][c][d]; if(a==c) { ++ile2[d][a][0]; ++ile2[b][a][2]; } if(b==d) { ++ile2[a][b][1]; ++ile2[c][b][3]; } } cout << ans << '\n'; }
#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...