제출 #855719

#제출 시각아이디문제언어결과실행 시간메모리
855719vjudge1Zamjena (COCI18_zamjena)C++17
70 / 70
449 ms8016 KiB
#pragma GCC optimize("unroll-loops", "O3") //author: Ahmet Alp Orakci #include <bits/stdc++.h> using namespace std; using i64 = long long; bool check(string &a) { bool ans = true; for(char &ch : a) { ans &= ('0' <= ch && ch <= '9'); if(!ans) return 0; } return ans; } #define ONLINE_JUDGE void solve() { int n; cin >> n; vector <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; vector <bool> vis(n +1); bool ans = true; for(int it = 1; it <= 100; it++) { for(int i = 1; i <= n; i++) { if(vis[i]) { continue; } if(check(a[i])) { if(check(b[i])) { if(a[i] != b[i]) { return cout << "NE", void(); } } else { if(mp.count(b[i])) { if(mp[b[i]] != a[i]) { return cout << "NE", void(); } } else { mp[b[i]] = a[i]; } } vis[i] = true; } else if(check(b[i])) { swap(a[i], b[i]); if(check(b[i])) { if(a[i] != b[i]) { return cout << "NE", void(); } } else { if(mp.count(b[i])) { if(mp[b[i]] != a[i]) { return cout << "NE", void(); } } else { mp[b[i]] = a[i]; } } vis[i] = true; swap(a[i], b[i]); } } for(int i = 1; i <= n; i++) { if(vis[i]) continue; if(mp.count(a[i])) { a[i] = mp[a[i]]; } if(mp.count(b[i])) { b[i] = mp[b[i]]; } } } cout << "DA"; return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

zamjena.cpp: In function 'void solve()':
zamjena.cpp:34:10: warning: unused variable 'ans' [-Wunused-variable]
   34 |     bool ans = true;
      |          ^~~
#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...