# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472357 | MamdouhN | Zamjena (COCI18_zamjena) | C++17 | 32 ms | 2960 KiB |
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 endl "\n"
map<string,string>idk;
main()
{
int n;
cin>>n;
string row1[n],row2[n];
for(int i=0;i<n;i++)cin>>row1[i];
for(int i=0;i<n;i++)cin>>row2[i];
for(int i=0;i<n;i++)
{
bool is_var1 = (row1[i][0]>='a'&&row1[i][0]<='z');
bool is_var2 = (row2[i][0]>='a'&&row2[i][0]<='z');
if(is_var1&&is_var2)continue;
if(is_var1)
{
if(idk[row1[i]]!="")
{
row1[i]=idk[row1[i]];
continue;
}
idk[row1[i]]=row2[i];
row1[i]=row2[i];
}
if(is_var2)
{
if(idk[row2[i]]!="")
{
row2[i]=idk[row2[i]];
continue;
}
idk[row2[i]]=row1[i];
row2[i]=row1[i];
}
}
//for(auto v:row1)cout<<v<<" ";
//cout<<endl;
//for(auto v:row2)cout<<v<<" ";
//cout<<endl;
for(int i=0;i<n;i++)
{
bool is_var1 = (row1[i][0]>='a'&&row1[i][0]<='z');
bool is_var2 = (row2[i][0]>='a'&&row2[i][0]<='z');
if(is_var1&&is_var2)
{
bool has_value1 = (idk[row1[i]]!="");
bool has_value2 = (idk[row2[i]]!="");
if(has_value1)row1[i]=idk[row1[i]];
else
{
idk[row1[i]]="1";
row1[i]="1";
}
if(has_value2)row2[i]=idk[row2[i]];
else
{
idk[row2[i]]="1";
row2[i]="1";
}
}
}
//for(auto v:row1)cout<<v<<" ";
//cout<<endl;
//for(auto v:row2)cout<<v<<" ";
//cout<<endl;
bool cando=1;
for(int i=0;i<n;i++)
{
if(row1[i]!=row2[i])cando=0;
}
cout<<(cando?"DA":"NE")<<endl;
}
Compilation message (stderr)
# | 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... |