이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]={};
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
{
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
{
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])
{
l1++;
r1++;
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);
}
long long h=ces1-m1s;
long long f=ces-m2s;
if(h==f)
{
cout<<"DA";
}
else cout<<"NE";
return 0;
}
컴파일 시 표준 에러 (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:75:11: warning: unused variable 'k' [-Wunused-variable]
75 | 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... |