#include<bits/stdc++.h>
using namespace std;
string dizi[100007];
string dizi2[100007];
unordered_map<string,vector<pair<int,bool>>>degisken;
unordered_map<string,string>act;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
// string gir;
for(int i=0;i<n;i++)
{
cin >> dizi[i];
if(!isdigit(dizi[i][0]))
{
degisken[dizi[i]].push_back({i,0});
}
}
for(int i=0;i<n;i++)
{
cin >> dizi2[i];
if(!isdigit(dizi2[i][0]))
{
degisken[dizi2[i]].push_back({i,1});
// if(isdigit(dizi[i][0]))
// {
// }
}
else
{
if(isdigit(dizi[i][0]))
{
if(dizi[i]!=dizi2[i])
{
cout << "NE\n";
exit(0);
}
}
}
}
for(int i=0;i<=n;i++)
{
// for(int i=0;i<n;i++)
// {
// cout << dizi[i] << " ";
// }
// cout <<"\n";
// for(int i=0;i<n;i++)
// {
// cout << dizi2[i] << " ";
// }
// cout <<"\n\n";
if(!isdigit(dizi[i][0]) && !isdigit(dizi2[i][0]) && dizi[i]!=dizi2[i])
{
// cout << i << " ";
string za=dizi2[i];
for(auto x:degisken[za])
{
degisken[dizi[i]].push_back(x);
// cout << x.first << " ";
if(x.second==0)
{
dizi[x.first]=dizi[i];
}
else
dizi2[x.first]=dizi[i];
}
degisken.erase(degisken.find(za));
}
}
for(int i=0;i<n;i++)
{
if(isdigit(dizi[i][0]) && !isdigit(dizi2[i][0]))
{
string muz=dizi[i],muz2=dizi2[i];
for(auto x:degisken[muz2])
{
if(x.second==0)
{
dizi[x.first]=muz;
}
else
dizi2[x.first]=muz;
}
degisken.erase(degisken.find(muz2));
}
else if(!isdigit(dizi[i][0])&& isdigit(dizi2[i][0]))
{
string muz=dizi2[i],muz2=dizi[i];
for(auto x:degisken[muz2])
{
if(x.second==0)
{
dizi[x.first]=muz;
}
else
dizi2[x.first]=muz;
}
degisken.erase(degisken.find(muz2));
}
}
/*for(int i=0;i<n;i++)
{
cout << dizi[i] << " ";
}
cout <<"\n";
for(int i=0;i<n;i++)
{
cout<< dizi2[i] << " ";
}*/
for(int i=0;i<n;i++)
{
if(dizi[i]!=dizi2[i])
{
cout <<"NE\n";
exit(0);
}
}
cout << "DA\n";
exit(0);
// for(int i=0;i<n;i++)
// {
// if(!isdigit(dizi[i][0]) && !isdigit(dizi2[i][0]))
// {
// for(auto x:degisken2[dizi2[i]])
// {
// // degisken[dizi[i]]
// }
// }
// }
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
7544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
6648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
6648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
7404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
7516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
7292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |