Submission #254077

#TimeUsernameProblemLanguageResultExecution timeMemory
254077MarkoesCards (LMIO19_korteles)C++14
100 / 100
153 ms19576 KiB
#include<bits/stdc++.h> using namespace std; int n,c[4],atas,bawah,kanan,kiri; char cc; long long satu,kdua,dua,kempat,empat,up[680],dn[680],le[680],ri[680],cas[6][680][680]; bool cek[30][30]; int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0);cout.tie(0); cin>>n; memset(up,0,sizeof up); memset(dn,0,sizeof dn); memset(le,0,sizeof le); memset(ri,0,sizeof ri); satu = 0; dua = 0; empat = 0; memset(cek,0,sizeof cek); for(int i=1;i<=n;i++){ for(int j=0;j<4;j++){ cin>>cc; c[j] = (int)(cc-'A'); } if(c[0] == c[3] && c[1] == c[2] && c[0] == c[1]){ kempat++; } else if(c[0] == c[1] && c[2] == c[3]) kdua++; else if(c[0] == c[2] && c[1] == c[3]) kdua++; else if(c[0] == c[3] && c[1] == c[2]){ cek[c[0]][c[1]] = 1; if(cek[c[1]][c[0]]){ empat++; } } atas = c[0]*26+c[1]; bawah = c[2]*26+c[3]; kanan = c[1]*26+c[3]; kiri = c[0]*26+c[2]; up[atas]++; dn[bawah]++; le[kiri]++; ri[kanan]++; cas[0][atas][bawah]++; cas[1][kiri][kanan]++; cas[2][kiri][atas]++; cas[3][atas][kanan]++; cas[4][kiri][bawah]++; cas[5][bawah][kanan]++; } // cout<<"kdua kempat empat "<<kdua<<' '<<kempat<<' '<<empat<<endl; for(int i=0;i<676;i++){ for(int j=0;j<676;j++){ dua += cas[0][i][j] * cas[0][j][i]; dua += cas[1][i][j] * cas[1][j][i]; dua += cas[2][i][j] * cas[5][j][i]; dua += cas[3][i][j] * cas[4][j][i]; dua += cas[4][i][j] * cas[3][j][i]; dua += cas[5][i][j] * cas[2][j][i]; } } // cout<<"dua bruto "<<dua<<endl; dua -= kempat*6; dua -= kdua; dua /= 2; dua -= empat*6; // cout<<"dua neto "<<dua<<endl; for(int i=0;i<676;i++){ satu += up[i]*dn[i]; satu += le[i]*ri[i]; satu += up[i]*dn[i]; satu += le[i]*ri[i]; } satu -= kempat*4; satu -= kdua*2; satu /= 2; satu -= dua*2; satu -= empat*4; // cout<<satu<<' '<<dua<<' '<<empat<<endl; cout<<satu+dua+empat<<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...