# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
595875 |
2022-07-14T07:49:18 Z |
KoD |
게임 (APIO22_game) |
C++17 |
|
1 ms |
296 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[u].push_back(v);
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |