#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 = 50005;
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 |
Correct |
2 ms |
5724 KB |
Output is correct |
2 |
Correct |
3 ms |
5724 KB |
Output is correct |
3 |
Correct |
2 ms |
5864 KB |
Output is correct |
4 |
Correct |
2 ms |
5724 KB |
Output is correct |
5 |
Correct |
3 ms |
5724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5724 KB |
Output is correct |
2 |
Incorrect |
3 ms |
5724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5720 KB |
Output is correct |
2 |
Correct |
3 ms |
5724 KB |
Output is correct |
3 |
Incorrect |
2 ms |
5776 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5980 KB |
Output is correct |
2 |
Correct |
3 ms |
5980 KB |
Output is correct |
3 |
Incorrect |
4 ms |
5972 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
6488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |