#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[2][N];
vector<int> g[2][N];
bool vis[2][N];
bool allDigit(string &s) {
for (char &c : s) if(c < '0' || c > '9') return 0;
return 1;
}
void dfs(int u, int f) {
vis[f][u] = 1;
cnt += allDigit(a[f][u]);
for (int v : g[f][u]) if (!vis[f^1][v])
dfs(v, f^1);
}
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[0][i];
fo(i, 1, n) cin >> a[1][i];
fo(i, 1, n) if (a[0][i] != a[1][i])
g[0][i].pb(i), g[1][i].pb(i);
fo(i, 1, n) if (!vis[0][i]) {
cnt = 0;
dfs(i, 0);
if (cnt > 1) {
cout << "NE";
return 0;
}
}
cout << "DA";
}
Compilation message
zamjena.cpp: In function 'int32_t main()':
zamjena.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen("A.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
29 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
40 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |