# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
610972 | 2022-07-28T20:48:22 Z | fvogel499 | Werewolf (IOI18_werewolf) | C++17 | 366 ms | 52300 KB |
#include "werewolf.h" #include <bits/stdc++.h> #define sz(x) ((x).size()) using namespace std; const int inf = 1e9; const int p2 = 1<<18; struct Segtree { Segtree() { t = new int [p2*2]; for (int i = 0; i < p2*2; i++) t[i] = -inf; } void upd(int x, int v) { for (x += p2; x; x /= 2) { t[x] = max(t[x], v); } } int get(int b, int e) { int r = -inf; b += p2; e += p2; while (b <= e) { if (b%2 == 1) { r = max(r, t[b]); b++; } if (e%2 == 0) { r = max(r, t[e]); e--; } b /= 2; e /= 2; } return r; } int* t; }; std::vector<int> check_validity(const int n, std::vector<int> edgeX, std::vector<int> edgeY, std::vector<int> queryX, std::vector<int> queryY, std::vector<int> queryLB, std::vector<int> queryRB) { vector<int> graph [n]; for (int i = 0; i < sz(edgeX); i++) { graph[edgeX[i]].push_back(edgeY[i]); graph[edgeY[i]].push_back(edgeX[i]); } vector<int> path; for (int i = 0; i < n; i++) if (sz(graph[i]) == 1) { bool vis [n]; for (int j = 0; j < n; j++) vis[j] = false; int x = i; while (1) { vis[x] = true; path.push_back(x); bool ch = false; for (int y : graph[x]) if (!vis[y]) { x = y; ch = true; break; } if (!ch) { break; } } break; } assert(sz(path) == n); int invPath [n]; for (int i = 0; i < n; i++) invPath[path[i]] = i; const int nbQ = sz(queryX); vector<int> queriesSmallerThan [n]; int latestPerQuery [nbQ]; vector<int> queriesBiggerThan [n]; int earliestPerQuery [nbQ]; for (int i = 0; i < nbQ; i++) { if (queryLB[i] >= 1) { queriesSmallerThan[queryLB[i] - 1].push_back(i); } else { latestPerQuery[i] = -1; } if (queryRB[i]+1 < n) { queriesBiggerThan[queryRB[i] + 1].push_back(i); } else { earliestPerQuery[i] = n; } } Segtree st = Segtree(); for (int i = 0; i < n; i++) { st.upd(invPath[i], invPath[i]); for (int j : queriesSmallerThan[i]) { latestPerQuery[j] = st.get(queryX[j], queryY[j]); } } st = Segtree(); for (int i = n-1; i >= 0; i--) { st.upd(invPath[i], -invPath[i]); for (int j : queriesBiggerThan[i]) { earliestPerQuery[j] = -st.get(queryX[j], queryY[j]); } } vector<int> res(nbQ); for (int i = 0; i < nbQ; i++) { res[i] = (latestPerQuery[i]+1 < earliestPerQuery[i]); } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 428 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 428 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 366 ms | 52300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 428 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |