Submission #472180

#TimeUsernameProblemLanguageResultExecution timeMemory
472180SaraMostafaZamjena (COCI18_zamjena)C++14
14 / 70
32 ms4972 KiB
#include <bits/stdc++.h> #include<unordered_map> using namespace std; #define ll long long #define endl "\n" #define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); const long long mod=998244353; const double PI=acos(-1); int main() { //freopen("input.in","r",stdin); Sara int n; cin>>n; vector<string>a(n),b(n); bool valid=1; for(int i=0; i<n; i++) { cin>>a[i]; } for(int i=0; i<n; i++) { cin>>b[i]; } map<string,string>mpd; for(int i=0; i<n; i++) { bool dia=isdigit(a[i][0]); bool dib=isdigit(b[i][0]); if(dia && dib) continue; else if(!dia && !dib) { continue; } else { if(dia ) { if(mpd[b[i]]=="" || mpd[b[i]]==a[i]) mpd[b[i]]=a[i]; else { valid=0; break; } } else { if(mpd[a[i]]=="" || mpd[a[i]]==b[i]) mpd[a[i]]=b[i]; else { valid=0; break; } } } } for(int i=0; i<n; i++) { bool dia=isdigit(a[i][0]); bool dib=isdigit(b[i][0]); if(dia || dib) continue; if(mpd[a[i]]=="" ) { if(mpd[b[i]]=="") continue; else mpd[a[i]]=mpd[b[i]]; } else if(mpd[b[i]]=="" ) { if(mpd[a[i]]=="") continue; else mpd[b[i]]=mpd[a[i]]; } else { if(mpd[a[i]]!=mpd[b[i]]) { valid=0; break; } } } if(!valid) cout<<"NE"<<endl; else cout<<"DA"<<endl; 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...