Submission #721242

#TimeUsernameProblemLanguageResultExecution timeMemory
721242vjudge1Zamjena (COCI18_zamjena)C++17
28 / 70
16 ms1492 KiB
#include <bits/stdc++.h> using namespace std; bool is_str(string s){ if(s[0] - '0' > 9){ return true; } return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<string> v1(n); map<string, string> mp; for(int i = 0; i < n; i++){ cin >> v1[i]; mp[v1[i]] = "-1"; } vector<string> v2(n); for(int i = 0; i < n; i++){ cin >> v2[i]; mp[v2[i]] = "-1"; } for(int i = 0; i < n; i++){ if(!is_str(v1[i]) && !is_str(v2[i]) && v1[i] != v2[i]){ cout << "NE" <<"\n"; return 0; } if(is_str(v1[i]) && !is_str(v2[i])){ if(mp[v1[i]] == "-1"){ mp[v1[i]] = v2[i]; } } if(!is_str(v1[i]) && is_str(v2[i])){ if(mp[v2[i]] == "-1"){ mp[v2[i]] = v1[i]; } } } for(int i = 0; i < n; i++){ if(mp[v1[i]] != "-1"){ v1[i] = mp[v1[i]]; } } for(int i = 0; i < n; i++){ if(mp[v2[i]] != "-1"){ v2[i] = mp[v2[i]]; } } /* for(int i = 0; i < n; i++){ cout << v1[i] <<" "; } cout <<"\n"; for(int i = 0; i < n; i++){ cout << v2[i] <<" "; } cout <<"\n"; */ for(int i = 0; i < n; i++){ if(!is_str(v1[i]) && !is_str(v2[i]) && v1[i] != v2[i]){ cout << "NE" <<"\n"; return 0; } if(is_str(v1[i]) && is_str(v2[i])){ v1[i] = "1"; v2[i] = "1"; } if(!is_str(v1[i]) && is_str(v2[i])){ if(mp[v2[i]] == "-1"){ mp[v2[i]] = v1[i]; } } if(is_str(v1[i]) && !is_str(v2[i])){ if(mp[v1[i]] == "-1"){ mp[v1[i]] = v2[i]; } } } for(int i = 0; i < n; i++){ if(mp[v1[i]] != "-1"){ v1[i] = mp[v1[i]]; } if(mp[v2[i]] != "-1"){ v2[i] = mp[v2[i]]; } } for(int i = 0; i < n; i++){ if(v1[i] != v2[i]){ cout << "NE" <<"\n"; return 0; } } cout << "DA" <<"\n"; /* 3 3 1 2 3 1 x 4 4 5 iks ipsilon 1 iks 3 iks 5 x 3 x y 3 x y 2 z 3 5 y 3 x z 4 z x y 2 4 */ }
#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...