제출 #253991

#제출 시각아이디문제언어결과실행 시간메모리
253991nabilervatraCards (LMIO19_korteles)C++14
100 / 100
503 ms70392 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; int n,satu,dua,empat,u,d,l,r; vector<int > pairu[459977],paird[459977],pairr[459977],pairl[459977]; bool tmp1[680],tmp2[680],tmp3[680],tmp4[680]; bool ada[459977]; string s[459977],abaw,tms1,tms2,kaki,tms,a,b; int hsh(string a){ return int(a[0]-'A')* 676*26+int(a[1]-'A')*676+int(a[2]-'A')*26+int(a[3]-'A'); } void ts(string &x, char a, char b, char c , char d){ x.pb(a); x.pb(b); x.pb(c); x.pb(d); } int main(){ cin>>n; for(int i =1;i<=n;i++){ a,b; cin>>a>>b; s[i] = a+b; u = (s[i][0]-'A')*26+ (s[i][1]-'A'); d = (s[i][2]-'A')*26+ (s[i][3]-'A'); l = (s[i][0]-'A')*26+ (s[i][2]-'A'); r = (s[i][1]-'A')*26+ (s[i][3]-'A'); pairu[u].pb(d); paird[d].pb(u); pairl[l].pb(r); pairr[r].pb(l); ada[hsh(s[i])]=1; } for(int i =0;i<26*26;i++){ satu+= pairu[i].size()*paird[i].size(); memset(tmp1,0,sizeof(tmp1)); memset(tmp2,0,sizeof(tmp2)); memset(tmp3,0,sizeof(tmp3)); memset(tmp4,0,sizeof(tmp4)); for(auto j :pairu[i])tmp1[j]=1; for(auto j :paird[i])tmp2[j]=1; if(tmp1[i]&&tmp2[i])satu--; satu+= pairl[i].size()*pairr[i].size(); for(auto j :pairl[i])tmp3[j]=1; for(auto j :pairr[i])tmp4[j]=1; if(tmp3[i]&&tmp4[i])satu--; } // cout<<satu<<endl; for(int i =1;i<=n;i++){ abaw=""; ts(abaw,s[i][2],s[i][3],s[i][0],s[i][1]); // cout<<abaw<<endl; kaki=""; ts(kaki,s[i][1],s[i][0],s[i][3],s[i][2]); if(s[i]!=abaw&&ada[hsh(abaw)])dua++; if(s[i]!=kaki&&ada[hsh(kaki)])dua++; if(s[i][0]==s[i][3]&&s[i][2]==s[i][1]){ tms = ""; ts(tms, s[i][1],s[i][0],s[i][3],s[i][2]); if(s[i]!=tms&&ada[hsh(tms)])empat++; } if(s[i][1]==s[i][2]){ for(char j = 'A' ;j<='Z';j++){ tms1=""; ts(tms1,j,s[i][0],s[i][0],s[i][1]); tms2 = ""; ts(tms2,s[i][1],s[i][3],s[i][3],j); if(s[i]!=tms1&&ada[hsh(tms1)])dua++; if(s[i]!=tms2&&ada[hsh(tms2)])dua++; } } if(s[i][0]==s[i][3]){ for(char j = 'A' ;j<='Z';j++){ tms1 =""; ts(tms1,s[i][1],j,s[i][0],s[i][1]); tms2 = ""; ts(tms2,s[i][2],s[i][0],j,s[i][2]); if(s[i]!=tms1&&ada[hsh(tms1)])dua++; if(s[i]!=tms2&&ada[hsh(tms2)])dua++; } } } // cout<<dua<<' '<<empat<<endl; cout<<satu- dua/2 + (empat/2)*3<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

korteles.cpp: In function 'int main()':
korteles.cpp:23:11: warning: left operand of comma operator has no effect [-Wunused-value]
         a,b;
           ^
korteles.cpp:23:12: warning: right operand of comma operator has no effect [-Wunused-value]
         a,b;
            ^
#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...