제출 #721201

#제출 시각아이디문제언어결과실행 시간메모리
721201vjudge1Zamjena (COCI18_zamjena)C++17
14 / 70
10 ms1604 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])){ v1[i] = v2[i]; if(mp[v1[i]] == "-1"){ mp[v1[i]] = v2[i]; } } if(!is_str(v1[i]) && is_str(v2[i])){ v2[i] = v1[i]; if(mp[v2[i]] == "-1"){ mp[v2[i]] = v1[i]; } } } for(int i = 0; i < n; i++){ if(mp[v1[i]] != "-1" && is_str(v1[i])){ v1[i] = mp[v1[i]]; } } for(int i = 0; i < n; i++){ if(mp[v2[i]] != "-1" && is_str(v2[i])){ v2[i] = mp[v2[i]]; } } for(int i = 0; i < n; i++){ if(is_str(v1[i]) && is_str(v2[i])){ v1[i] = "1"; v2[i] = "1"; } } for(int i = 0; i < n; i++){ if(v1[i] != v2[i]){ cout << "NE" <<"\n"; return 0; } } /* for(int i = 0; i < n; i++){ cout << v1[i] <<" "; } cout <<"\n"; for(int i = 0; i < n; i++){ cout << v2[i] <<" "; } cout <<"\n"; */ 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 */ }
#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...