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 fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
const int N = 1e6+5;
int n, cnt = 0;
string a[N], b[N];
map<string, bool> vis;
map<string, vector<string>> g;
bool allDigit(string &s) {
for (char c : s) if(c < '0' || c > '9') return 0;
return 1;
}
void dfs(string u) {
vis[u] = 1;
cnt += allDigit(u);
for (string &v : g[u]) if (!vis[v]) dfs(v);
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("A.inp", "r")) {
freopen("A.inp", "r", stdin);
// freopen("A.out", "w", stdout);
}
cin >> n;
fo(i, 1, n) cin >> a[i];
fo(i, 1, n) cin >> b[i];
fo(i, 1, n) if (a[i] != b[i])
g[a[i]].pb(b[i]), g[b[i]].pb(a[i]);
fo(i, 1, n) if (!vis[a[i]]) {
cnt = 0;
dfs(a[i]);
if (cnt > 1) {
cout << "NE";
return 0;
}
}
cout << "DA";
}
Compilation message (stderr)
zamjena.cpp: In function 'int32_t main()':
zamjena.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen("A.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# | 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... |