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>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=998244353;
const double PI=acos(-1);
int main()
{
//freopen("input.in","r",stdin);
Sara
int n;
cin>>n;
vector<string>a(n),b(n);
bool valid=1;
for(int i=0; i<n; i++)
{
cin>>a[i];
}
for(int i=0; i<n; i++)
{
cin>>b[i];
}
map<string,string>mpd;
for(int i=0; i<n; i++)
{
bool dia=isdigit(a[i][0]);
bool dib=isdigit(b[i][0]);
if(dia && dib)
{
if(a[i]!=b[i]){
valid=0;
break;
}
continue;
}
else if(!dia && !dib)
{
continue;
}
else
{
if(dia )
{
if(mpd[b[i]]=="" || mpd[b[i]]==a[i])
mpd[b[i]]=a[i];
else
{
valid=0;
break;
}
}
else
{
if(mpd[a[i]]=="" || mpd[a[i]]==b[i])
mpd[a[i]]=b[i];
else
{
valid=0;
break;
}
}
}
}
for(int i=0; i<n; i++)
{
bool dia=isdigit(a[i][0]);
bool dib=isdigit(b[i][0]);
if(dia || dib)
continue;
if(mpd[a[i]]=="" )
{
if(mpd[b[i]]=="")
continue;
else
mpd[a[i]]=mpd[b[i]];
}
else if(mpd[b[i]]=="" )
{
if(mpd[a[i]]=="")
continue;
else
mpd[b[i]]=mpd[a[i]];
}
else
{
if(mpd[a[i]]!=mpd[b[i]])
{
valid=0;
break;
}
}
}
if(!valid)
cout<<"NE"<<endl;
else
cout<<"DA"<<endl;
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... |