Submission #1025663

#TimeUsernameProblemLanguageResultExecution timeMemory
1025663vjudge1Zamjena (COCI18_zamjena)C++17
14 / 70
3 ms1112 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a[n], b[n]; for (int i=0;i<n;i++) cin >> a[i]; for (int i=0;i<n;i++) cin >> b[i]; map<string, int> vrednost; int aa[n], bb[n]; memset(aa, -1, sizeof(aa)); memset(bb, -1, sizeof(bb)); for (int i=0;i<n;i++) { int br1=-1, br2=-1; if (a[i][0]-'0'<=9) br1=stoi(a[i]); if (b[i][0]-'0'<=9) br2=stoi(b[i]); if (br1!=-1&&br2!=-1) { if (br1!=br2) { cout << "NE"; return 0; } aa[i]=br1, bb[i]=br2; } else if (br1!=-1) { int v=vrednost[b[i]]; if (v==0) vrednost[b[i]]=br1; else if (v!=br1) { cout << "NE"; return 0; } aa[i]=br1, bb[i]=br1; } else if (br2!=-1) { int v=vrednost[a[i]]; if (v==0) vrednost[a[i]]=br2; else if (v!=br2) { cout << "NE"; return 0; } aa[i]=br2, bb[i]=br2; } } for (int i=0;i<n;i++) { if (aa[i]!=-1&&bb[i]!=-1) { if (aa[i]!=bb[i]) { cout << "NE"; return 0; } } else if (aa[i]!=-1) { int v=vrednost[b[i]]; if (v==0) vrednost[b[i]]=aa[i]; else if (v!=aa[i]) { cout << "NE"; return 0; } bb[i]=aa[i]; } else if (bb[i]!=-1) { int v=vrednost[a[i]]; if (v==0) vrednost[a[i]]=bb[i]; else if (v!=bb[i]) { cout << "NE"; return 0; } aa[i]=bb[i]; } } cout << "DA"; 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...