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 pb push_back
int n, cond;
string a[50005], b[50005];
map<string, vector<string> > adj;
set<string> vis;
void dfs(string u){
vis.insert(u);
cond += isdigit(u[0]);
for(auto v : adj[u]) if(vis.find(v) == vis.end()) dfs(v);
}
int main(){
int n; 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]].pb(b[i]);
adj[b[i]].pb(a[i]);
}
}
for(auto u : adj){
if(vis.find(u.first) == vis.end()){
cond = 0; dfs(u.first);
if(cond > 1){
cout << "NE\n"; return 0;
}
}
}
cout << "DA\n";
}
# | 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... |