Submission #588484

#TimeUsernameProblemLanguageResultExecution timeMemory
588484mpawicka_77Cards (LMIO19_korteles)C++14
100 / 100
190 ms14944 KiB
#include <bits/stdc++.h> using namespace std; int L[27][27]; int D[27][27]; int G[27][27]; int P[27][27]; int LD[27][27][27][27]; int LP[27][27][27][27]; int LG[27][27][27][27]; int PD[27][27][27][27]; int PG[27][27][27][27]; int DG[27][27][27][27]; int LPDG[27][27]; int f(int a,int b,int c,int d) { int w=0; w=L[b][d]+P[a][c]+D[a][b]+G[c][d]-LD[b][d][a][b]-LP[b][d][a][c]-LG[b][d][c][d]-PD[a][c][a][b]-PG[a][c][c][d]-DG[a][b][c][d]; if(a==d&&b==c)w+=3*LPDG[c][d]; return w; } void dodaj(int a,int b,int c,int d) { L[a][c]++; P[b][d]++; D[c][d]++; G[a][b]++; LP[a][c][b][d]++; LD[a][c][c][d]++; LG[a][c][a][b]++; PD[b][d][c][d]++; PG[b][d][a][b]++; DG[c][d][a][b]++; if(a==d&&b==c)LPDG[a][b]++; } int main() { int n; cin>>n; long long w=0; for(int i=0;i<n;i++) { char x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; int a=x1-'A',b=y1-'A',c=x2-'A',d=y2-'A'; w+=f(a,b,c,d); dodaj(a,b,c,d); } cout<<w; return 0; }
#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...