# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472305 | Mr_OK_Man | Zamjena (COCI18_zamjena) | C++17 | 303 ms | 15540 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;
long long c=0,n;
long long r=0;
string a[50001]={},b[50001]={};
map<string,vector<string>>mp;
map<string,vector<string>>mp1;
map<string,bool>v;
void dfs(string x)
{
if(isdigit(x[0]))
{
r++;
}
v[x]=1;
for(auto i:mp[x])
{
if(v[i]==0)
{
dfs(i);
}
}
}
int main()
{
// cout << "Hello world!" << endl;
cin>>n;
long long as=0,a1s=0,bs=0,b1s=0;
for(int i=0;i<n;i++)
{
string s;
cin>>s;
long long r=0;
a[i]=s;
}
for(int i=0;i<n;i++)
{
string s;
cin>>s;
b[i]=s;
mp[a[i]].push_back(s);
mp[s].push_back(a[i]);
}
long long q=0;
for(int i=0;i<n;i++)
{
r=0;
if(isdigit(a[i][0])&&isdigit(b[i][0]))
{
if(a[i]!=b[i])
{
q=1;
break;
}
}
else
{
if(isdigit(a[i][0]))
{
dfs(b[i]);
}
else
{
dfs(a[i]);
}
if(r>1)
{
q=1;
break;
}
}
}
if(q==1)
{
cout<<"NE"<<endl;
}
else
{
cout<<"DA"<<endl;
}
//sort(a,a+as);
//sort(a1,a1+a1s);
//sort(b,b+bs);
//sort(b1,b1+b1s);
return 0;
}
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... |