Submission #448310

# Submission time Handle Problem Language Result Execution time Memory
448310 2021-07-29T15:17:09 Z MOUF_MAHMALAT Tenis (COI19_tenis) C++14
30 / 100
500 ms 6588 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

tenis.cpp: In function 'int main()':
tenis.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);
      |     ~~~~~^~~~~~~~~~~~~~
tenis.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]);
      |             ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d",&t);
      |         ~~~~~^~~~~~~~~
tenis.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);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
tenis.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 54 ms 5660 KB Output is correct
14 Correct 51 ms 5348 KB Output is correct
15 Correct 55 ms 6200 KB Output is correct
16 Correct 61 ms 6088 KB Output is correct
17 Correct 86 ms 6360 KB Output is correct
18 Correct 69 ms 6368 KB Output is correct
19 Correct 74 ms 6348 KB Output is correct
20 Correct 39 ms 5080 KB Output is correct
21 Correct 79 ms 6352 KB Output is correct
22 Correct 64 ms 6356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 6588 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 54 ms 5660 KB Output is correct
14 Correct 51 ms 5348 KB Output is correct
15 Correct 55 ms 6200 KB Output is correct
16 Correct 61 ms 6088 KB Output is correct
17 Correct 86 ms 6360 KB Output is correct
18 Correct 69 ms 6368 KB Output is correct
19 Correct 74 ms 6348 KB Output is correct
20 Correct 39 ms 5080 KB Output is correct
21 Correct 79 ms 6352 KB Output is correct
22 Correct 64 ms 6356 KB Output is correct
23 Execution timed out 1091 ms 6588 KB Time limit exceeded
24 Halted 0 ms 0 KB -