제출 #185647

#제출 시각아이디문제언어결과실행 시간메모리
185647anonymousTenis (COI19_tenis)C++14
51 / 100
1076 ms9148 KiB
#include<iostream>
#include<queue>
#define MAXN 100005
using namespace std;
int N,Q, L[MAXN][3], Pos[MAXN][3], Worst[3][3][MAXN]; //(i,j,k) lowest ranked player on court type i in first k of court type j
bool done[MAXN];
int f1=1, f2=1, f3=1; //frontiers
int op, qa, qb, qc;
queue <int> q;
void slv() {
    f1=1, f2=1, f3=1;
    for (int i=0; i<3; i++) {
        for (int j=1; j<=N; j++) {
            Pos[L[j][i]][i]=j;
        }
    }
    for (int i=0; i<3; i++) {
        for (int j=1; j<=N; j++) {
            for (int k=0; k<3; k++) {
                Worst[i][k][j]=0;
            } //i is current court, k is court being maximised, j is prefix
        }
    }
    for (int i=0; i<3; i++) {
        for (int j=1; j<=N; j++) {
            for (int k=0; k<3; k++) {
                Worst[i][k][j]=max(max(Worst[i][k][j], Worst[i][k][j-1]), Pos[L[j][i]][k]);
            } //i is current court, k is court being maximised, j is prefix
        }
    }
    while (true) {
        int pf1=f1, pf2=f2, pf3=f3;
        int A[3]={f1,f2,f3};
        for (int i=0; i<3; i++) {
            f1=max(f1, Worst[0][i][A[i]]);
            f2=max(f2, Worst[1][i][A[i]]);
            f3=max(f3, Worst[2][i][A[i]]);
        }
        //printf("%d %d %d\n",f1,f2,f3);
        if (f1 == pf1 && f2 == pf2 && f3 == pf3) {break;}
    }

}

bool ask(int x) {
    return(Pos[x][0] <= f1 || Pos[x][1] <= f2 || Pos[x][2] <= f3);
}
int main() {
    //freopen("tenin.txt","r",stdin);
    scanf("%d %d",&N,&Q);
    for (int i=0; i<3; i++) {
        for (int j=1; j<=N; j++) {
            scanf("%d", &L[j][i]);
        }
    }
    slv();
    for (int i=0; i<Q; i++) {
        scanf("%d", &op);
        if (op == 2) {
            scanf("%d %d %d", &qa, &qb, &qc);
            swap(L[Pos[qb][qa-1]][qa-1], L[Pos[qc][qa-1]][qa-1]);
            slv();
        } else {
            scanf("%d", &qa);
            printf("%s\n", ask(qa) ? "DA" : "NE");
        }
    }
}

컴파일 시 표준 에러 (stderr) 메시지

tenis.cpp: In function 'int main()':
tenis.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&N,&Q);
     ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:53:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &L[j][i]);
             ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &op);
         ~~~~~^~~~~~~~~~~
tenis.cpp:60:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d %d", &qa, &qb, &qc);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
tenis.cpp:64:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &qa);
             ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...