Submission #233287

#TimeUsernameProblemLanguageResultExecution timeMemory
233287NONAMETenis (COI19_tenis)C++17
18 / 100
1093 ms12280 KiB
#include <bits/stdc++.h> #define sz(x) int(x.size()) #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #define N 100500 #define oo ll(1e16) #define ft first #define sd second #define mp make_pair #define pb push_back #define ppb pop_back #define el '\n' #define elf endl #define base ll(1e9 + 7) using namespace std; typedef long long ll; typedef long double ld; int n, q, pos[3][N], a[3][N]; bool mk[N]; bool f(int v) { set <int> s, all; fill(mk, mk + n, 0); queue <int> q; q.push(v); // for (int i = 0; i < 3; i++, cerr << el) // for (int j = 0; j < n; j++) // cerr << a[i][j] + 1 << ' '; // cerr << el; while (!q.empty()) { s.clear(); int v = q.front(); q.pop(); mk[v] = 1; for (int t = 0; t < 3; t++) for (int i = pos[t][v] + 1; i < n; i++) { int x = a[t][i]; if (mk[x]) break; if (all.find(x) == all.end()) all.insert(x), s.insert(x); } for (int x : s) mk[x] = 1, q.push(x); } bool ok = 1; for (int i = 0; i < n; i++) ok &= mk[i]; return ok; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // in("input.txt"); cin >> n >> q; for (int t = 0; t < 3; t++) for (int i = 0; i < n; i++) { cin >> a[t][i]; a[t][i]--; pos[t][a[t][i]] = i; } while (q--) { int type; cin >> type; if (type == 1) { int x; cin >> x; x--; bool ok = f(x); cout << ((ok) ? "DA" : "NE") << el; } if (type == 2) { int x, y, z; cin >> x >> y >> z; x--; y--; z--; swap(pos[x][y], pos[x][z]); swap(a[x][pos[x][y]], a[x][pos[x][z]]); } } }
#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...