#include<bits/stdc++.h>
using namespace std;
const int N = 50005;
int n, ts, P[N + N], C[N + N];
string A[N], B[N];
map < string , int > M;
int Find(int v)
{
return (P[v] ? (P[v] = Find(P[v])) : v);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> A[i];
if (!M.count(A[i]))
M[A[i]] = ++ ts;
}
for (int i = 1; i <= n; i++)
{
cin >> B[i];
if (!M.count(B[i]))
M[B[i]] = ++ ts;
if (Find(M[A[i]]) != Find(M[B[i]]))
P[Find(M[A[i]])] = Find(M[B[i]]);
}
for (auto X : M)
if (X.first[0] <= '9')
C[Find(X.second)] ++;
for (int i = 1; i <= ts; i++)
if (C[i] >= 2)
return !printf("NE\n");
return !printf("DA\n");
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3448 KB |
Output is correct |
2 |
Correct |
4 ms |
3448 KB |
Output is correct |
3 |
Correct |
4 ms |
3448 KB |
Output is correct |
4 |
Correct |
4 ms |
3448 KB |
Output is correct |
5 |
Correct |
4 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3448 KB |
Output is correct |
2 |
Correct |
4 ms |
3448 KB |
Output is correct |
3 |
Correct |
4 ms |
3448 KB |
Output is correct |
4 |
Correct |
4 ms |
3448 KB |
Output is correct |
5 |
Correct |
4 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3576 KB |
Output is correct |
2 |
Correct |
4 ms |
3448 KB |
Output is correct |
3 |
Correct |
4 ms |
3448 KB |
Output is correct |
4 |
Correct |
4 ms |
3448 KB |
Output is correct |
5 |
Correct |
4 ms |
3448 KB |
Output is correct |
6 |
Correct |
4 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3576 KB |
Output is correct |
2 |
Correct |
5 ms |
3576 KB |
Output is correct |
3 |
Correct |
8 ms |
3704 KB |
Output is correct |
4 |
Correct |
8 ms |
3704 KB |
Output is correct |
5 |
Correct |
8 ms |
3704 KB |
Output is correct |
6 |
Correct |
8 ms |
3704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
4060 KB |
Output is correct |
2 |
Correct |
37 ms |
4856 KB |
Output is correct |
3 |
Correct |
69 ms |
5744 KB |
Output is correct |
4 |
Correct |
87 ms |
6040 KB |
Output is correct |
5 |
Correct |
139 ms |
7672 KB |
Output is correct |
6 |
Correct |
99 ms |
5624 KB |
Output is correct |