이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,a[4][1100000],b[4][4][1100000],perm[4][1100000],e,ee;
ll f(ll w)
{
ll i,x,y,z,xx=0,yy=0,zz=0;
for(i=1;i<=n;i++)
{
b[1][2][i]=max(b[1][2][i-1],a[2][perm[1][i]]);
b[1][3][i]=max(b[1][3][i-1],a[3][perm[1][i]]);
b[2][1][i]=max(b[2][1][i-1],a[1][perm[2][i]]);
b[2][3][i]=max(b[2][3][i-1],a[3][perm[2][i]]);
b[3][1][i]=max(b[3][1][i-1],a[1][perm[3][i]]);
b[3][2][i]=max(b[3][2][i-1],a[2][perm[3][i]]);
}
x=a[1][w];
y=a[2][w];
z=a[3][w];
//printf("(%lld:%lld %lld %lld)\n",w,x,y,z);
while(x<n&&y<n&&z<n)
{
//printf("%lld %lld %lld:%lld %lld %lld\n",x,y,z,xx,yy,zz);
xx=max(b[2][1][y],b[3][1][z]);
yy=max(b[1][2][x],b[3][2][z]);
zz=max(b[1][3][x],b[2][3][y]);
if(x==xx&&y==yy&&z==zz)
break;
x=xx;
y=yy;
z=zz;
}
if(x<n&&y<n&&z<n)
return 0;
else
return 1;
}
int main()
{
scanf("%lld %lld",&n,&e);
for(i=1;i<=n;i++)
{
scanf("%lld",&x);
a[1][x]=n+1-i;
perm[1][a[1][x]]=x;
}
for(i=1;i<=n;i++)
{
scanf("%lld",&x);
a[2][x]=n+1-i;
perm[2][a[2][x]]=x;
}
for(i=1;i<=n;i++)
{
scanf("%lld",&x);
a[3][x]=n+1-i;
perm[3][a[3][x]]=x;
}
for(i=1;i<=n;i++)
{
// printf("[%lld %lld %lld]\n",a[1][i],a[2][i],a[3][i]);
}
//printf("!");
for(ee=0;ee<e;ee++)
{
scanf("%lld",&x);
if(x==1)
{
scanf("%lld",&y);
if(f(y))
printf("DA\n");
else
printf("NE\n");
continue;
}
scanf("%lld %lld %lld",&z,&x,&y);
swap(a[z][x],a[z][y]);
perm[z][a[z][x]]=x;
perm[z][a[z][y]]=y;
/*for(i=1;i<=n;i++)
{
printf("(%lld,%lld,%lld)\n",a[1][i],a[2][i],a[3][i]);
}
for(i=1;i<=n;i++)
{
printf("[%lld,%lld,%lld]\n",perm[1][i],perm[2][i],perm[3][i]);
}*/
}
}
컴파일 시 표준 에러 (stderr) 메시지
tenis.cpp: In function 'int main()':
tenis.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%lld %lld",&n,&e);
| ~~~~~^~~~~~~~~~~~~~~~~~~
tenis.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
tenis.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
tenis.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
55 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
tenis.cpp:66:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
66 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
tenis.cpp:69:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
69 | scanf("%lld",&y);
| ~~~~~^~~~~~~~~~~
tenis.cpp:76:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
76 | scanf("%lld %lld %lld",&z,&x,&y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |