Submission #472300

#TimeUsernameProblemLanguageResultExecution timeMemory
472300Ahmed_SolymanZamjena (COCI18_zamjena)C++14
56 / 70
185 ms15588 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; bool isNum(string s){ return (s[0]>='1' && s[0]<='9'); } int main() { ll n;cin>>n; vector<string>a(n),b(n); for(auto &i:a)cin>>i; for(auto &i:b)cin>>i; bool v=1; map<string,string>mp; map<string,bool>vis; map<string,vector<string>>u; for(ll i=0;i<n;i++){ if(vis[a[i]]){ a[i]=mp[a[i]]; } if(vis[b[i]]){ b[i]=mp[b[i]]; } if(isNum(a[i]) && isNum(b[i])){ v&=(a[i]==b[i]); } else if(isNum(a[i])){ for(auto j:u[b[i]]){ if(vis[j]){ v&=(mp[j] == a[i]); } else{ vis[j]=1; mp[j]=a[i]; } } vis[b[i]]=1; mp[b[i]]=a[i]; } else if(isNum(b[i])){ for(auto j:u[a[i]]){ if(vis[j]){ v&=(mp[j] == b[i]); } else{ vis[j]=1; mp[j]=b[i]; } } vis[a[i]]=1; mp[a[i]]=b[i]; } else{ u[a[i]].push_back(b[i]); u[b[i]].push_back(a[i]); } } if(v){ cout<<"DA"; } else{ cout<<"NE"; } 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...