This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 50005
using namespace std;
struct elem
{
string s,t;
}v[N];
int n,i,j;
map<string,string> m;
bool vrf()
{
string s,t;
for(i=1;i<=n;++i)
{
s=v[i].s;
t=v[i].t;
if(s[0]<='9' && t[0]<='9' && s!=t) return 0;
else if(s[0]<='9' && t[0]>'9')
{
if(m.count(t) && m[t]!=s) return 0;
m[t]=s;
}
else if(s[0]>'9' && t[0]<='9')
{
if(m.count(s) && m[s]!=t) return 0;
m[s]=t;
}
}
for(i=1;i<=n;++i)
{
s=v[i].s;
t=v[i].t;
if(s[0]>'9' && t[0]>'9')
{
if(m.count(t) && m.count(s) && m[t]!=m[s]) return 0;
else if(m.count(t) && !m.count(s)) m[s]=m[t];
else if(!m.count(t) && m.count(s)) m[t]=m[s];
}
}
return 1;
}
int main()
{
cin>>n;
for(i=1;i<=n;++i)
{
cin>>v[i].s;
}
for(i=1;i<=n;++i)
{
cin>>v[i].t;
}
if(vrf()) cout<<"DA";
else cout<<"NE";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |