Submission #751600

#TimeUsernameProblemLanguageResultExecution timeMemory
751600Username4132Tenis (COI19_tenis)C++14
51 / 100
1083 ms9112 KiB
#include<iostream>
#include<set>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)

const int MAXN=100010;
int n, q, arr[3][MAXN], inv[3][MAXN];
set<int> winners;

void calc(){
    winners.clear();
    forn(i, n){
        forn(j, 3) winners.insert(arr[j][i]);
        if((int)winners.size()==i+1) break;
    }
}

int main(){
    scanf("%d %d", &n, &q);
    forn(i, 3) forn(j, n) scanf("%d", &arr[i][j]), --arr[i][j], inv[i][arr[i][j]]=j;
    calc();
    forn(i, q){
        int type; scanf("%d", &type);
        if(type==1){
            int x; scanf("%d", &x); --x;
            printf("%s\n", winners.find(x)==winners.end()? "NE\n" : "DA\n");
        }
        else{
            int p, a, b; scanf("%d %d %d", &p, &a, &b); --p, --a, --b;
            int posA=inv[p][a], posB=inv[p][b];
            swap(arr[p][posA], arr[p][posB]);
            swap(inv[p][a], inv[p][b]);
            calc();
        }
    }
}

Compilation message (stderr)

tenis.cpp: In function 'int main()':
tenis.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tenis.cpp:20:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     forn(i, 3) forn(j, n) scanf("%d", &arr[i][j]), --arr[i][j], inv[i][arr[i][j]]=j;
      |                           ~~~~~^~~~~~~~~~~~~~~~~~
tenis.cpp:23:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         int type; scanf("%d", &type);
      |                   ~~~~~^~~~~~~~~~~~~
tenis.cpp:25:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |             int x; scanf("%d", &x); --x;
      |                    ~~~~~^~~~~~~~~~
tenis.cpp:29:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |             int p, a, b; scanf("%d %d %d", &p, &a, &b); --p, --a, --b;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...