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;
typedef long long ll;
int main()
{
int n ;
cin >> n;
string a[n+1],b[n+1];
for(int i= 1; i<=n ;i++)
{
cin >> a[i];
}
for(int i= 1; i<=n ;i++)
{
cin >> b[i];
}
map<string,string>mp;
bool first,second;
for(int i= 1; i<=n ;i++)
{
first=false;
second=false;
if(a[i]!=b[i])
{
if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0)
{
first=true;
}
if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0)
{
second=true;
}
if(first&&second&&a[i]!=b[i])
{
cout << "NO\n";
return 0;
}
if(first)
{
if(mp[b[i]]!="")
{
cout << "NO\n";
return 0;
}
mp[b[i]]=a[i];
}
if(second)
{
if(mp[a[i]]!="")
{
cout << "NE\n";
return 0;
}
mp[a[i]]=b[i];
}
}
}
for(int i = 1 ; i<=n ;i++)
{
first=false;
second=false;
if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0)
{
first=true;
}
if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0)
{
second=true;
}
if(first&&second)
continue;
if(first)
{
b[i]=mp[b[i]];
}
if(second)
{
a[i]=mp[a[i]];
}
}
for(int i = 1; i <=n ;i++)
{
first=false;
second=false;
if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0)
{
first=true;
}
if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0)
{
second=true;
}
if(first&&second&&a[i]!=b[i])
{
cout << "NE\n";
return 0;
}
}
cout << "DA\n";
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... |