Submission #144264

#TimeUsernameProblemLanguageResultExecution timeMemory
144264SamAndTenis (COI19_tenis)C++17
18 / 100
73 ms504 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1003; struct ban { int x, y, z; }; int n, q; ban a[N], b[N]; bool c[N]; void bil() { memset(c, false, sizeof c); set<int> sx, sy, sz; set<int> s; for (int i = n; i > 1; --i) { sx.insert(a[i].x); sy.insert(a[i].y); sz.insert(a[i].z); if (sx == sy && sy == sz) { s = sx; } } for (set<int>::iterator it = s.begin(); it != s.end(); ++it) c[*it] = true; } int main() { scanf("%d%d", &n, &q); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].x); b[a[i].x].x = i; } for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].y); b[a[i].y].y = i; } for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].z); b[a[i].z].z = i; } bil(); while (q--) { int ty; scanf("%d", &ty); if (ty == 1) { int x; scanf("%d", &x); if (c[x] == false) printf("DA\n"); else printf("NE\n"); } else { int p, x, y; scanf("%d%d%d", &p, &x, &y); if (p == 1) { swap(a[b[x].x].x, a[b[y].x].x); swap(b[x].x, b[y].x); } else if (p == 2) { swap(a[b[x].y].y, a[b[y].y].y); swap(b[x].y, b[y].y); } else { swap(a[b[x].z].z, a[b[y].z].z); swap(b[x].z, b[y].z); } bil(); } } return 0; }

Compilation message (stderr)

tenis.cpp: In function 'int main()':
tenis.cpp:35: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:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i].x);
         ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i].y);
         ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i].z);
         ~~~~~^~~~~~~~~~~~~~~
tenis.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &ty);
         ~~~~~^~~~~~~~~~~
tenis.cpp:59:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
tenis.cpp:68:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d%d", &p, &x, &y);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...