Submission #385258

#TimeUsernameProblemLanguageResultExecution timeMemory
385258penguinhackerZamjena (COCI18_zamjena)C++14
70 / 70
187 ms16364 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int n, c; string a[50000], b[50000]; set<string> vis; map<string, vector<string>> adj; void dfs(string u) { vis.insert(u); c += isdigit(u[0]); for (string v : adj[u]) if (vis.find(v) == vis.end()) dfs(v); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i]; for (int i = 0; i < n; ++i) if (a[i] != b[i]) { adj[a[i]].push_back(b[i]); adj[b[i]].push_back(a[i]); } for (auto& x : adj) if (vis.find(x.first) == vis.end()) { c = 0, dfs(x.first); if (c > 1) { cout << "NE"; return 0; } } 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...