답안 #908031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908031 2024-01-16T07:15:02 Z ibm2006 Tenis (COI19_tenis) C++17
30 / 100
500 ms 22208 KB
#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]);
        }*/
    }
}

Compilation message

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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12636 KB Output is correct
2 Correct 3 ms 12736 KB Output is correct
3 Correct 3 ms 12636 KB Output is correct
4 Correct 3 ms 12736 KB Output is correct
5 Correct 3 ms 12636 KB Output is correct
6 Correct 3 ms 12636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12636 KB Output is correct
2 Correct 3 ms 12736 KB Output is correct
3 Correct 3 ms 12636 KB Output is correct
4 Correct 3 ms 12736 KB Output is correct
5 Correct 3 ms 12636 KB Output is correct
6 Correct 3 ms 12636 KB Output is correct
7 Correct 3 ms 12632 KB Output is correct
8 Correct 3 ms 12636 KB Output is correct
9 Correct 3 ms 12740 KB Output is correct
10 Correct 3 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 4 ms 12636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12636 KB Output is correct
2 Correct 3 ms 12736 KB Output is correct
3 Correct 3 ms 12636 KB Output is correct
4 Correct 3 ms 12736 KB Output is correct
5 Correct 3 ms 12636 KB Output is correct
6 Correct 3 ms 12636 KB Output is correct
7 Correct 3 ms 12632 KB Output is correct
8 Correct 3 ms 12636 KB Output is correct
9 Correct 3 ms 12740 KB Output is correct
10 Correct 3 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 4 ms 12636 KB Output is correct
13 Correct 57 ms 22104 KB Output is correct
14 Correct 30 ms 22096 KB Output is correct
15 Correct 29 ms 22100 KB Output is correct
16 Correct 33 ms 22192 KB Output is correct
17 Correct 32 ms 22208 KB Output is correct
18 Correct 34 ms 22096 KB Output is correct
19 Correct 35 ms 22200 KB Output is correct
20 Correct 25 ms 14276 KB Output is correct
21 Correct 32 ms 22164 KB Output is correct
22 Correct 30 ms 22088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1058 ms 20572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12636 KB Output is correct
2 Correct 3 ms 12736 KB Output is correct
3 Correct 3 ms 12636 KB Output is correct
4 Correct 3 ms 12736 KB Output is correct
5 Correct 3 ms 12636 KB Output is correct
6 Correct 3 ms 12636 KB Output is correct
7 Correct 3 ms 12632 KB Output is correct
8 Correct 3 ms 12636 KB Output is correct
9 Correct 3 ms 12740 KB Output is correct
10 Correct 3 ms 12636 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 4 ms 12636 KB Output is correct
13 Correct 57 ms 22104 KB Output is correct
14 Correct 30 ms 22096 KB Output is correct
15 Correct 29 ms 22100 KB Output is correct
16 Correct 33 ms 22192 KB Output is correct
17 Correct 32 ms 22208 KB Output is correct
18 Correct 34 ms 22096 KB Output is correct
19 Correct 35 ms 22200 KB Output is correct
20 Correct 25 ms 14276 KB Output is correct
21 Correct 32 ms 22164 KB Output is correct
22 Correct 30 ms 22088 KB Output is correct
23 Execution timed out 1058 ms 20572 KB Time limit exceeded
24 Halted 0 ms 0 KB -