답안 #448309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448309 2021-07-29T15:15:22 Z MOUF_MAHMALAT Izlet (COI19_izlet) C++11
0 / 100
2 ms 332 KB
#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
using namespace std;
typedef int ll;
ll n,q,a[100009][4],id[100009][4],t,op[4],x,y,z;
queue<ll>dq;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    scanf("%d%d",&n,&q);
    for(ll j=1; j<=3; j++)
        for(ll i=1; i<=n; i++)
        {
            scanf("%d",&a[i][j]);
            id[a[i][j]][j]=i;
        }
    while(q--)
    {
        scanf("%d",&t);
        if(t-1)
        {
            scanf("%d%d%d",&z,&x,&y);
            swap(a[id[x][z]][z],a[id[y][z]][z]);
            swap(id[x][z],id[y][z]);
            continue;
        }
        scanf("%d",&x);
        for(ll i=1; i<=3; i++)
            op[i]=n;
        dq.push(x);
        while(!dq.empty())
        {
            x=dq.front();
            dq.pop();
            for(ll j=1; j<=3; j++)
            {
                y=z=id[x][j];
                while(y<=op[j])
                {
                    dq.push(a[y][j]);
                    y++;
                }
                op[j]=min(op[j],z-1);
            }
        }
        sort(op+1,op+4);
        if(op[1])
            printf("NE\n");
        else
            printf("DA\n");
    }
    return 0;
}

Compilation message

izlet.cpp: In function 'int main()':
izlet.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
izlet.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf("%d",&a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~
izlet.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d",&t);
      |         ~~~~~^~~~~~~~~
izlet.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |             scanf("%d%d%d",&z,&x,&y);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
izlet.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Expected integer, but "NE" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Expected integer, but "NE" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Expected integer, but "NE" found
2 Halted 0 ms 0 KB -