Submission #151407

#TimeUsernameProblemLanguageResultExecution timeMemory
151407phillipZamjena (COCI18_zamjena)C++14
28 / 70
32 ms7548 KiB
#include <bits/stdc++.h> using namespace std; string s[100009],s2[100009]; int n,val[100009]; map<string,int>m; int main() { cin>>n; m["0"]=0; m["1"]=1; m["2"]=2; m["3"]=3; m["4"]=4; m["5"]=5; m["6"]=6; m["7"]=7; m["8"]=8; m["9"]=9; memset(val,-1,sizeof(val)); for(int i=0;i<n;i++) { cin>>s[i]; if(s[i].size()==1&&(s[i][0]-'0'<=9))val[i]=s[i][0]-'0'; else m[s[i]]=-1; } for(int i=0;i<n;i++) { cin>>s2[i]; if(s2[i].size()==1&&(s2[i][0]-'0'<=9))val[i]=s2[i][0]-'0'; else m[s2[i]]=-1; } for(int i=0;i<n;i++) { if(m[s[i]]==-1&&m[s2[i]]==-1)continue; else if(m[s[i]]!=-1&&m[s2[i]]!=-1&&m[s[i]]!=m[s2[i]]){cout<<"NE";/*1 "<<i<<" "<<m[s[i]]<<" "<<m[s2[i]]*/;return 0;} m[s[i]]=max(m[s[i]],m[s2[i]]); m[s2[i]]=max(m[s[i]],m[s2[i]]); } for(int i=0;i<n;i++) { if(m[s[i]]==-1&&m[s2[i]]==-1)continue; else if(m[s[i]]!=-1&&m[s2[i]]!=-1&&m[s[i]]!=m[s2[i]]){cout<<"NE";return 0;} m[s[i]]=max(m[s[i]],m[s2[i]]); m[s2[i]]=max(m[s[i]],m[s2[i]]); } cout<<"DA"; }
#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...