#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define int long long
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,avx")
#pragma GCC optimize("unroll-loops")
int n,m;
string a[50005];
string b[50005];
map<string,string> par;
map<string,int> mark;
int mal;
string bul(string x)
{
if(par[x]==x)
return x;
return par[x]=bul(par[x]);
}
void add(string x,string y)
{
x=bul(x);
y=bul(y);
if(x==y)
return;
if(x[0]<='9'&&y[0]>='a')
par[y]=x;
else if(x[0]<='9'&&y[0]<='9')
{
mal=1;
return;
}
else if(x[0]>='a'&&y[0]<='9')
par[x]=y;
else par[y]=par[x];
}
void solve()
{
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
cin>>b[i];
for(int i=0;i<n;i++)
{
par[a[i]]=a[i];
par[b[i]]=b[i];
}
for(int i=0;i<n;i++)
{
if(a[i]==b[i])
continue;
else add(a[i],b[i]);
}
if(mal==1)
{
cout<<"NE"<<endl;
return;
}
cout<<"DA"<<endl;
}
signed main()
{
fast1
//freopen ("lca.gir","r",stdin);
//freopen ("lca.cik","w",stdout);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3408 KB |
Output is correct |
2 |
Correct |
3 ms |
3408 KB |
Output is correct |
3 |
Correct |
3 ms |
3408 KB |
Output is correct |
4 |
Correct |
2 ms |
3408 KB |
Output is correct |
5 |
Correct |
3 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3408 KB |
Output is correct |
2 |
Correct |
2 ms |
3408 KB |
Output is correct |
3 |
Correct |
2 ms |
3408 KB |
Output is correct |
4 |
Correct |
2 ms |
3388 KB |
Output is correct |
5 |
Correct |
2 ms |
3408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3408 KB |
Output is correct |
2 |
Correct |
2 ms |
3452 KB |
Output is correct |
3 |
Correct |
2 ms |
3408 KB |
Output is correct |
4 |
Correct |
2 ms |
3452 KB |
Output is correct |
5 |
Correct |
2 ms |
3408 KB |
Output is correct |
6 |
Correct |
2 ms |
3408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3532 KB |
Output is correct |
2 |
Correct |
4 ms |
3440 KB |
Output is correct |
3 |
Correct |
7 ms |
3604 KB |
Output is correct |
4 |
Correct |
8 ms |
3664 KB |
Output is correct |
5 |
Correct |
7 ms |
3664 KB |
Output is correct |
6 |
Correct |
6 ms |
3588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
4048 KB |
Output is correct |
2 |
Correct |
43 ms |
5020 KB |
Output is correct |
3 |
Correct |
89 ms |
6336 KB |
Output is correct |
4 |
Correct |
99 ms |
6624 KB |
Output is correct |
5 |
Correct |
162 ms |
8688 KB |
Output is correct |
6 |
Correct |
106 ms |
6092 KB |
Output is correct |