Submission #908597

#TimeUsernameProblemLanguageResultExecution timeMemory
908597lightonTenis (COI19_tenis)C++17
51 / 100
1066 ms9672 KiB
#include<bits/stdc++.h> #define forf(i,a,b) for(int i = a; i<=b; i++) #define all(v) v.begin(),v.end() typedef long long ll; using namespace std; int N,Q; int rnk[3][100001]; int pos[3][100001]; int cnt[100001]; set<int> possible; void findpossible(){ forf(i,1,N) cnt[i] = 0; int noncomplete = 0; possible.clear(); forf(i,1,N){ forf(j,0,2){ cnt[rnk[j][i]]++; if(cnt[rnk[j][i]] == 1){ noncomplete++; possible.insert(rnk[j][i]); } if(cnt[rnk[j][i]] == 3) noncomplete--; } if(noncomplete == 0) return; } } int main(){ scanf("%d %d" , &N,&Q); forf(i,0,2) forf(j,1,N){ scanf("%d" , &rnk[i][j]); pos[i][rnk[i][j]] = j; } findpossible(); while(Q--){ int cmd; scanf("%d" ,&cmd); if(cmd==1){ int t; scanf("%d" , &t); if(possible.find(t) == possible.end()) printf("NE\n"); else printf("DA\n"); } else{ int i,a,b;scanf("%d %d %d" , &i,&a,&b); i--; swap(rnk[i][pos[i][a]],rnk[i][pos[i][b]]); swap(pos[i][a],pos[i][b]); findpossible(); } } }

Compilation message (stderr)

tenis.cpp: In function 'int main()':
tenis.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d %d" , &N,&Q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tenis.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d" , &rnk[i][j]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
tenis.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         scanf("%d" ,&cmd);
      |         ~~~~~^~~~~~~~~~~~
tenis.cpp:39:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |             int t; scanf("%d" , &t);
      |                    ~~~~~^~~~~~~~~~~
tenis.cpp:44:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |             int i,a,b;scanf("%d %d %d" , &i,&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...