#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 = 50050;
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
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 |
1 |
Correct |
2 ms |
3420 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
1 ms |
3592 KB |
Output is correct |
4 |
Correct |
2 ms |
3420 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3420 KB |
Output is correct |
2 |
Correct |
1 ms |
3592 KB |
Output is correct |
3 |
Correct |
2 ms |
3588 KB |
Output is correct |
4 |
Correct |
2 ms |
3420 KB |
Output is correct |
5 |
Correct |
2 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3596 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3420 KB |
Output is correct |
4 |
Correct |
1 ms |
3420 KB |
Output is correct |
5 |
Correct |
2 ms |
3420 KB |
Output is correct |
6 |
Correct |
2 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3676 KB |
Output is correct |
2 |
Correct |
3 ms |
3676 KB |
Output is correct |
3 |
Correct |
3 ms |
3932 KB |
Output is correct |
4 |
Correct |
5 ms |
4188 KB |
Output is correct |
5 |
Correct |
5 ms |
4188 KB |
Output is correct |
6 |
Correct |
4 ms |
4120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
5708 KB |
Output is correct |
2 |
Correct |
30 ms |
7760 KB |
Output is correct |
3 |
Correct |
32 ms |
9028 KB |
Output is correct |
4 |
Correct |
41 ms |
10836 KB |
Output is correct |
5 |
Correct |
114 ms |
16380 KB |
Output is correct |
6 |
Correct |
69 ms |
11956 KB |
Output is correct |