| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 792940 | Trisanu_Das | Zamjena (COCI18_zamjena) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
c += 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) == v.end()){
c = 0; dfs(u.first);
if(c > 1){
cout << "NE\n"; return 0;
}
}
}
cout << "DA\n";
}
