Submission #611764

# Submission time Handle Problem Language Result Execution time Memory
611764 2022-07-29T07:14:37 Z 조영욱(#8499) Tenis (COI19_tenis) C++17
100 / 100
230 ms 3680 KB
#include <bits/stdc++.h>
using namespace std;

const int sz=131072;
int seg[sz*2];
int lazy[sz*2];

void prop(int node) {
    if (lazy[node]!=0) {
        seg[node]+=lazy[node];
        if (node<sz) {
            lazy[node*2]+=lazy[node];
            lazy[node*2+1]+=lazy[node];
        }
        lazy[node]=0;
    }
}

void update(int l,int r,int val,int node=1,int nodel=0,int noder=sz-1) {
    prop(node);
    if (r<nodel||l>noder) {
        return;
    }
    if (l<=nodel&&noder<=r) {
        lazy[node]+=val;
        prop(node);
        return;
    }
    int mid=(nodel+noder)/2;
    update(l,r,val,node*2,nodel,mid);
    update(l,r,val,node*2+1,mid+1,noder);
    seg[node]=min(seg[node*2],seg[node*2+1]);
}

int find() {
    int node=1;
    prop(1);
    while (node<sz) {
        prop(node*2);
        prop(node*2+1);
        if (seg[node*2]==0) {
            node=node*2;
        }
        else {
            node=node*2+1;
        }
    }
    return node-sz;
}

int arr[100001][3];

int main() {
    int n,q;
    scanf("%d %d",&n,&q);
    update(0,0,1);
    for(int j=0;j<3;j++) {
        for(int i=1;i<=n;i++) {
            int x;
            scanf("%d",&x);
            arr[x][j]=i;
        }
    }
    for(int i=1;i<=n;i++) {
        int mn=1e9+7;
        int mx=0;
        for(int j=0;j<3;j++) {
            mn=min(mn,arr[i][j]);
            mx=max(mx,arr[i][j]);
        }
        update(mn,mx-1,1);
    }
    for(int i=0;i<q;i++) {
        int type;
        scanf("%d",&type);
        if (type==1) {
            int x;
            scanf("%d",&x);
            int pos=1e9+7;
            for(int j=0;j<3;j++) {
                pos=min(pos,arr[x][j]);
            }
            if (find()<pos) {
                printf("NE\n");
            }
            else {
                printf("DA\n");
            }
        }
        else {
            int p,a,b;
            scanf("%d %d %d",&p,&a,&b);
            p--;
            int mn=1e9+7;
            int mx=0;
            for(int j=0;j<3;j++) {
                mn=min(mn,arr[a][j]);
                mx=max(mx,arr[a][j]);
            }
            update(mn,mx-1,-1);
            mn=1e9+7;
            mx=0;
            for(int j=0;j<3;j++) {
                mn=min(mn,arr[b][j]);
                mx=max(mx,arr[b][j]);
            }
            update(mn,mx-1,-1);
            swap(arr[a][p],arr[b][p]);
            mn=1e9+7;
            mx=0;
            for(int j=0;j<3;j++) {
                mn=min(mn,arr[a][j]);
                mx=max(mx,arr[a][j]);
            }
            update(mn,mx-1,1);
            mn=1e9+7;
            mx=0;
            for(int j=0;j<3;j++) {
                mn=min(mn,arr[b][j]);
                mx=max(mx,arr[b][j]);
            }
            update(mn,mx-1,1);
        }
    }
    return 0;
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:60:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
tenis.cpp:75:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         scanf("%d",&type);
      |         ~~~~~^~~~~~~~~~~~
tenis.cpp:78:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
tenis.cpp:92:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |             scanf("%d %d %d",&p,&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 2 ms 316 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 2 ms 316 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 62 ms 3292 KB Output is correct
14 Correct 72 ms 3228 KB Output is correct
15 Correct 64 ms 3284 KB Output is correct
16 Correct 61 ms 3292 KB Output is correct
17 Correct 64 ms 3212 KB Output is correct
18 Correct 52 ms 3252 KB Output is correct
19 Correct 58 ms 3172 KB Output is correct
20 Correct 65 ms 3240 KB Output is correct
21 Correct 72 ms 3244 KB Output is correct
22 Correct 60 ms 3388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 3680 KB Output is correct
2 Correct 81 ms 3636 KB Output is correct
3 Correct 79 ms 3584 KB Output is correct
4 Correct 89 ms 3528 KB Output is correct
5 Correct 84 ms 3552 KB Output is correct
6 Correct 102 ms 3596 KB Output is correct
7 Correct 86 ms 3564 KB Output is correct
8 Correct 94 ms 3596 KB Output is correct
9 Correct 104 ms 3548 KB Output is correct
10 Correct 92 ms 3576 KB Output is correct
11 Correct 91 ms 3564 KB Output is correct
12 Correct 103 ms 3552 KB Output is correct
13 Correct 91 ms 3560 KB Output is correct
14 Correct 89 ms 3532 KB Output is correct
15 Correct 91 ms 3580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 2 ms 316 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 62 ms 3292 KB Output is correct
14 Correct 72 ms 3228 KB Output is correct
15 Correct 64 ms 3284 KB Output is correct
16 Correct 61 ms 3292 KB Output is correct
17 Correct 64 ms 3212 KB Output is correct
18 Correct 52 ms 3252 KB Output is correct
19 Correct 58 ms 3172 KB Output is correct
20 Correct 65 ms 3240 KB Output is correct
21 Correct 72 ms 3244 KB Output is correct
22 Correct 60 ms 3388 KB Output is correct
23 Correct 86 ms 3680 KB Output is correct
24 Correct 81 ms 3636 KB Output is correct
25 Correct 79 ms 3584 KB Output is correct
26 Correct 89 ms 3528 KB Output is correct
27 Correct 84 ms 3552 KB Output is correct
28 Correct 102 ms 3596 KB Output is correct
29 Correct 86 ms 3564 KB Output is correct
30 Correct 94 ms 3596 KB Output is correct
31 Correct 104 ms 3548 KB Output is correct
32 Correct 92 ms 3576 KB Output is correct
33 Correct 91 ms 3564 KB Output is correct
34 Correct 103 ms 3552 KB Output is correct
35 Correct 91 ms 3560 KB Output is correct
36 Correct 89 ms 3532 KB Output is correct
37 Correct 91 ms 3580 KB Output is correct
38 Correct 230 ms 3336 KB Output is correct
39 Correct 107 ms 3500 KB Output is correct
40 Correct 212 ms 3384 KB Output is correct
41 Correct 133 ms 3388 KB Output is correct
42 Correct 127 ms 3568 KB Output is correct
43 Correct 192 ms 3412 KB Output is correct
44 Correct 109 ms 3532 KB Output is correct
45 Correct 158 ms 3428 KB Output is correct
46 Correct 144 ms 3472 KB Output is correct
47 Correct 145 ms 3420 KB Output is correct
48 Correct 114 ms 3548 KB Output is correct
49 Correct 119 ms 3484 KB Output is correct
50 Correct 135 ms 3476 KB Output is correct
51 Correct 119 ms 3532 KB Output is correct
52 Correct 204 ms 3404 KB Output is correct
53 Correct 155 ms 3432 KB Output is correct
54 Correct 140 ms 3368 KB Output is correct
55 Correct 133 ms 3444 KB Output is correct
56 Correct 133 ms 3464 KB Output is correct
57 Correct 113 ms 3504 KB Output is correct
58 Correct 156 ms 3580 KB Output is correct