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;
#define int long long
#define pb push_back
const int mod=1e9+7;
map<string,string>mp;
int n;
string s[5001];
string s2[5001];
signed main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>s[i];
}
for(int i=0;i<n;i++)
{
cin>>s2[i];
}
for(int i=0;i<n;i++)
{
bool isv=(s[i][0]<='z'&&s[i][0]>='a');
bool isv2=(s2[i][0]<='z'&&s2[i][0]>='a');
if(isv&&isv2)
{
s[i]=mp[s[i]];
s2[i]=mp[s2[i]];
if(s[i]==""||s2[i]=="") continue;
if(s[i]!=s2[i])
{
puts("NE");
return 0;
}
continue;
}
if(isv)
{
if(mp[s[i]]!=""&&mp[s[i]]!=s2[i])
{
puts("NE");
return 0;
}
if(mp[s[i]]=="") mp[s[i]]=s2[i];
continue;
}
if(isv2)
{
if(mp[s2[i]]!=""&&mp[s2[i]]!=s[i])
{
puts("NE");
return 0;
}
if(mp[s2[i]]=="") mp[s2[i]]=s[i];
continue;
}
if(s[i]!=s2[i])
{
puts("NE");
return 0;
}
}
for(int i=0;i<n/2;i++)
{
swap(s[i],s[n-i-1]);
swap(s2[i],s2[n-i-1]);
}
for(int i=0;i<n;i++)
{
bool isv=(s[i][0]<='z'&&s[i][0]>='a');
bool isv2=(s2[i][0]<='z'&&s2[i][0]>='a');
if(isv&&isv2)
{
s[i]=mp[s[i]];
s2[i]=mp[s2[i]];
if(s[i]==""||s2[i]=="") continue;
if(s[i]!=s2[i])
{
puts("NE");
return 0;
}
continue;
}
if(isv)
{
if(mp[s[i]]!=""&&mp[s[i]]!=s2[i])
{
puts("NE");
return 0;
}
if(mp[s[i]]=="") mp[s[i]]=s2[i];
continue;
}
if(isv2)
{
if(mp[s2[i]]!=""&&mp[s2[i]]!=s[i])
{
puts("NE");
return 0;
}
if(mp[s2[i]]=="") mp[s2[i]]=s[i];
continue;
}
if(s[i]!=s2[i])
{
puts("NE");
return 0;
}
}
puts("DA");
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... |