# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
595923 |
2022-07-14T08:06:10 Z |
KoD |
Game (APIO22_game) |
C++17 |
|
1 ms |
208 KB |
#include "game.h"
#include <utility>
#include <vector>
using std::pair;
using std::vector;
int N, K;
vector<vector<int>> graph, revgraph;
vector<pair<int, int>> interval;
bool shrink_interval(int u, int a, int b) {
auto& [l, r] = interval[u];
const int m = l + (r - l) / 2;
if (b < m) {
r = m;
shrink_interval(u, a, b);
return true;
}
if (m <= a) {
l = m;
shrink_interval(u, a, b);
return true;
}
return false;
}
void init(int n, int k) {
N = n, K = k;
graph.resize(n);
revgraph.resize(n);
interval.resize(n, pair(-1, k + 1));
for (int i = 0; i < k; ++i) {
shrink_interval(i, i - 1, i + 1);
}
}
bool update_max(int u, int x) {
if (interval[u].second <= x) return true;
if (shrink_interval(u, x, interval[u].second)) {
for (const int v : graph[u]) {
if (update_max(v, x)) return true;
}
}
return false;
}
bool update_min(int u, int x) {
if (x <= interval[u].first) return true;
if (shrink_interval(u, interval[u].first, x)) {
for (const int v : revgraph[u]) {
if (update_min(v, x)) return true;
}
}
return false;
}
int add_teleporter(int u, int v) {
graph[u].push_back(v);
revgraph[v].push_back(u);
if (update_max(v, u < K ? u : interval[u].first)) return true;
if (update_min(u, v < K ? v : interval[v].second)) return true;
return false;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
4 |
Halted |
0 ms |
0 KB |
- |