Submission #222638

#TimeUsernameProblemLanguageResultExecution timeMemory
222638kingfran1907Tenis (COI19_tenis)C++14
51 / 100
1085 ms5756 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; int n, q; int niz[3][maxn]; int pos[3][maxn]; bool bio[maxn]; int las[3]; queue< int > qs; void bfs() { memset(las, -1, sizeof las); memset(bio, false, sizeof bio); bio[niz[0][0]] = true; qs.push(niz[0][0]); bio[niz[1][0]] = true; qs.push(niz[1][0]); bio[niz[2][0]] = true; qs.push(niz[2][0]); while (!qs.empty()) { int x = qs.front(); qs.pop(); for (int i = 0; i < 3; i++) { for (int j = las[i] + 1; j <= pos[i][x]; j++) { if (!bio[niz[i][j]]) { qs.push(niz[i][j]); bio[niz[i][j]] = true; } } las[i] = max(las[i], pos[i][x]); } } } int main() { scanf("%d%d", &n, &q); for (int i = 0; i < 3; i++) for (int j = 0; j < n; j++) scanf("%d", &niz[i][j]); for (int i = 0; i < 3; i++) for (int j = 0; j < n; j++) pos[i][niz[i][j]] = j; bfs(); for (int i = 0; i < q; i++) { int type; scanf("%d", &type); if (type == 1) { int x; scanf("%d", &x); if (bio[x]) printf("DA\n"); else printf("NE\n"); } else { int p, a, b; scanf("%d%d%d", &p, &a, &b); p--; int pa = pos[p][a], pb = pos[p][b]; swap(niz[p][pa], niz[p][pb]); swap(pos[p][a], pos[p][b]); bfs(); } } return 0; }

Compilation message (stderr)

tenis.cpp: In function 'int main()':
tenis.cpp:38: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:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &niz[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~
tenis.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &type);
         ~~~~~^~~~~~~~~~~~~
tenis.cpp:53:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
tenis.cpp:58:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d%d", &p, &a, &b); p--;
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...