Submission #145465

#TimeUsernameProblemLanguageResultExecution timeMemory
145465youssan_williamZamjena (COCI18_zamjena)C++14
0 / 70
9 ms888 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n ; cin >> n; string a[n+1],b[n+1]; for(int i= 1; i<=n ;i++) { cin >> a[i]; } for(int i= 1; i<=n ;i++) { cin >> b[i]; } map<string,string>mp; bool first,second; for(int i= 1; i<=n ;i++) { first=false; second=false; if(a[i]!=b[i]) { if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0) { first=true; } if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0) { second=true; } if(first&&second&&a[i]!=b[i]) { cout << "NO\n"; return 0; } if(first) { if(mp[b[i]]!=""&&mp[b[i]]!=a[i]) { cout << "NO\n"; return 0; } mp[b[i]]=a[i]; } if(second) { if(mp[a[i]]!=""&&mp[a[i]]!=b[i]) { cout << "NE\n"; return 0; } mp[a[i]]=b[i]; } } } for(int i = 1 ; i<=n ;i++) { first=false; second=false; if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0) { first=true; } if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0) { second=true; } if(first&&second) continue; if(first) { b[i]=mp[b[i]]; } if(second) { a[i]=mp[a[i]]; } } for(int i = 1; i <=n ;i++) { first=false; second=false; if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0) { first=true; } if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0) { second=true; } if(first&&second&&a[i]!=b[i]) { cout << "NE\n"; return 0; } } cout << "DA\n"; 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...