Submission #611744

# Submission time Handle Problem Language Result Execution time Memory
611744 2022-07-29T07:04:49 Z 조영욱(#8499) Tenis (COI19_tenis) C++17
0 / 100
86 ms 4040 KB
#include <bits/stdc++.h>
using namespace std;

int n,q;
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[100000][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[i][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:56:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:61:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
tenis.cpp:76:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         scanf("%d",&type);
      |         ~~~~~^~~~~~~~~~~~
tenis.cpp:79:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
tenis.cpp:93:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |             scanf("%d %d %d",&p,&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 4040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -