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>
using namespace std;
string s[100009],s2[100009];
int n,val[100009];
map<string,int>m;
int main()
{
cin>>n;
m["0"]=0;
m["1"]=1;
m["2"]=2;
m["3"]=3;
m["4"]=4;
m["5"]=5;
m["6"]=6;
m["7"]=7;
m["8"]=8;
m["9"]=9;
memset(val,-1,sizeof(val));
for(int i=0;i<n;i++)
{
cin>>s[i];
if(s[i].size()==1&&(s[i][0]-'0'<=9))val[i]=s[i][0]-'0';
else m[s[i]]=-1;
}
for(int i=0;i<n;i++)
{
cin>>s2[i];
if(s2[i].size()==1&&(s2[i][0]-'0'<=9))val[i]=s2[i][0]-'0';
else m[s2[i]]=-1;
}
for(int i=0;i<n;i++)
{
if(m[s[i]]==-1&&m[s2[i]]==-1)continue;
else if(m[s[i]]!=-1&&m[s2[i]]!=-1&&m[s[i]]!=m[s2[i]]){cout<<"NE";/*1 "<<i<<" "<<m[s[i]]<<" "<<m[s2[i]]*/;return 0;}
m[s[i]]=max(m[s[i]],m[s2[i]]);
m[s2[i]]=max(m[s[i]],m[s2[i]]);
}
for(int i=0;i<n;i++)
{
if(m[s[i]]==-1&&m[s2[i]]==-1)continue;
else if(m[s[i]]!=-1&&m[s2[i]]!=-1&&m[s[i]]!=m[s2[i]]){cout<<"NE";return 0;}
m[s[i]]=max(m[s[i]],m[s2[i]]);
m[s2[i]]=max(m[s[i]],m[s2[i]]);
}
cout<<"DA";
}
# | 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... |