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;
int main()
{
long long c=0,n;
cin>>n;
long long a[n]={},b[n]={};
string a1[n]={},b1[n]={};
map<string,long long>mp;
map<string,long long>mp1;
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;
for(auto i:s)
{
if(isdigit(i))
{break;
}else
{
r=1;
break;
}
}
if(r==0)
{
long long q=stol(s);
a[as]=q;
as++;
}
else
{
mp[s]++;
a1[a1s]=s;
a1s++;
}
}
for(int i=0;i<n;i++)
{
string s;
cin>>s;
long long r=0;
for(auto i:s)
{
if(isdigit(i))
{
r=0;
break;
}
else
{
r=1;
break;
}
}
if(r==0)
{
long long q=stol(s);
b[bs]=q;
bs++;
}
else
{
mp1[s]++;
// cout<<s<<" "<<mp1[s]<<endl;
b1[b1s]=s;
b1s++;
}
}
sort(a,a+as);
sort(a1,a1+a1s);
sort(b,b+bs);
sort(b1,b1+b1s);
//for(int i=0;i<a1s;i++)cout<<a1[i]<<endl;
long long k=min(as,bs);
/*long long m=max(as,bs)-k,z;
if(as>=bs)
{
z=1;
}
else z=0;*/
//cout<<"e"<<endl;
long long l=0,r=0,m1s=0,m2s=0,ces=0,ces1=0;
//cout<<a[0]<<" "<<b[0]<<endl;
while(l<as&&r<bs)
{
//cout<<l<<" "<<r<<endl;
if(a[l]==b[r])
{
l++;
r++;
continue;
}
if(a[l]<b[r])
{
l++;
m1s++;
continue;
}
else
{
r++;
m2s++;
continue;
}
}
if(l==as&&r==bs)
{
}
else if(l==as)
{
m2s+=abs(bs-l);
}
else
{
m1s+=abs(as-r);
}
//
//
//
long long l1=0,r1=0;
while(l1<a1s&&r1<b1s)
{
if(a1[l1]==b1[r1])
{
// cout<<a1[l1]<<" "<<mp[a1[l1]]<<endl;
if(mp[a1[l1]]>mp1[b1[r1]])
{
// cout<<"e"<<endl;
ces++;
}
else if(mp1[b1[r1]]>mp[a1[l1]])
{
ces1++;
}
l1+=mp[a1[l1]];
// ll+=mp[a1[l1]];
r1+=mp1[b1[r1]];
// cout<<mp[a1[l1]]<<" "<<mp1[b1[r1]]<<endl;
// ces1++;
continue;
}
if(a1[l1]<b1[r1])
{
l1++;
ces++;
}
else if(b1[r1]<a1[l1])
{
r1++;
ces1++;
}
}
if(l1==a1s&&r1==b1s)
{
}
else if(l1==a1s)
{
ces1+=abs(b1s-l1);
}
else
{
ces+=abs(a1s-r1);
}
//cout<<ces<<" "<<ces1<<endl;
long long h=ces1-m1s;
long long f=ces-m2s;
if(h==f&&h>=0)
{
cout<<"DA";
}
else cout<<"NE";
return 0;
}
Compilation message (stderr)
zamjena.cpp: In function 'int main()':
zamjena.cpp:7:14: warning: unused variable 'c' [-Wunused-variable]
7 | long long c=0,n;
| ^
zamjena.cpp:80:11: warning: unused variable 'k' [-Wunused-variable]
80 | long long k=min(as,bs);
| ^
# | 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... |