Submission #85335

#TimeUsernameProblemLanguageResultExecution timeMemory
85335314rateZamjena (COCI18_zamjena)C++14
70 / 70
560 ms8680 KiB
#include <bits/stdc++.h> using namespace std; const int N=50000+5; int n; string a[N]; string b[N]; inline bool nr(string x) { if('0'<=x[0] && x[0]<='9') { return 1; } else { return 0; } } inline void e(string a) { cout<<a<<"\n"; exit(0); } map<string,string>h; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=n;i++) { cin>>b[i]; } for(int k=1;k<=10;k++){ for(int i=1;i<=n;i++) { if(nr(a[i]) && nr(b[i])) { if(a[i]!=b[i]) { e("NE"); } } } for(int i=1;i<=n;i++) { for(int k=1;k<=2;k++) { if(nr(a[i])==1 && nr(b[i])==0) { if(h[b[i]]=="" || h[b[i]]==a[i]) { h[b[i]]=a[i]; } else { e("NE"); } } swap(a[i],b[i]); } } for(int i=1;i<=n;i++) { if(nr(a[i])==0 && h[a[i]]!="") { a[i]=h[a[i]]; } if(nr(b[i])==0 && h[b[i]]!="") { b[i]=h[b[i]]; } } } for(int i=1;i<=n;i++) { /// cout<<a[i]<<" < - > "<<b[i]<<"\n"; } e("DA"); return 0; } /** 5 x 3 x y 3 x y 2 z 3 **/
#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...