Submission #253989

# Submission time Handle Problem Language Result Execution time Memory
253989 2020-07-29T08:34:14 Z nabilervatra Cards (LMIO19_korteles) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define pb push_back
using namespace std;
int n,satu,dua,empat;
vector<vector<int> > pairu(676*676),paird(676*676),pairr(676*676),pairl(676*676);
bool tmp1[680],tmp2[680],tmp3[680],tmp4[680];
bool ada[676*676];
string s[676*676],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');
        int 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;
}

Compilation message

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;
            ^
korteles.cpp:26:9: error: 'u' was not declared in this scope
         u = (s[i][0]-'A')*26+ (s[i][1]-'A');
         ^
korteles.cpp:27:9: error: 'd' was not declared in this scope
         d = (s[i][2]-'A')*26+ (s[i][3]-'A');
         ^
korteles.cpp:28:9: error: 'l' was not declared in this scope
         l = (s[i][0]-'A')*26+ (s[i][2]-'A');
         ^