This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |