Submission #620243

#TimeUsernameProblemLanguageResultExecution timeMemory
620243MinaRagy06Zamjena (COCI18_zamjena)C++17
70 / 70
156 ms16152 KiB
#include <bits/stdc++.h> using namespace std; #define lesgooo ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define endl '\n' #define int long long map<string, vector<string>> adj; set<string> vis; int cur= -1; bool ok = 1; void dfs(string i) { if (!ok) return; vis.insert(i); bool isnum = 1; for (auto x : i) if (x < '0' || x > '9') {isnum = 0; break;} if (isnum) { int num = 0; for (auto x : i) num = num*10 + (x-'0'); if (cur == -1 || cur == num ) cur = num; else ok = 0; } for (auto nxt : adj[i]) if (vis.find(nxt) == vis.end()) dfs(nxt); } signed main() { lesgooo; int n; cin >> n; vector<string> a(n), b(n); for (auto &i : a) cin >> i; for (auto &i : b) cin >> i; for (int i = 0; i < n; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]); for (auto i : adj) { if (vis.find(i.first) == vis.end()) cur = -1, dfs(i.first); if (!ok) break; } cout << (ok? "DA" : "NE"); 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...