# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
897085 |
2024-01-02T14:18:25 Z |
d4xn |
게임 (APIO22_game) |
C++17 |
|
1 ms |
2648 KB |
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
const int N = 3e4+4, K = 1e3+3, inf = INT_MAX;
bool cycle;
int n, k, mn[N];
bitset<N> bt[K];
vector<int> adj[N];
void dfs(int x, int y) {
if (bt[x][y]) return;
bt[x][y] = 1;
mn[x] = min({mn[x], mn[y], y});
for (int& z : adj[y]) {
if (bt[x][z]) continue;
dfs(x, z);
}
}
void init(int N, int K) {
n = N;
k = K;
cycle = 0;
for (int i = 0; i < n; i++) {
adj[i].clear();
mn[i] = (i < k-1 ? k-1 : inf);
}
for (int i = 0; i < k; i++) {
bt[i].reset();
}
}
int add_teleporter(int u, int v) {
if (cycle) return 1;
if (u < k && u == v) return cycle = 1;
adj[u].push_back(v);
if (min(u, v) >= k) {
for (int i = 0; i < k; i++) {
if (!bt[i][u]) continue;
bt[i][v] = 1;
adj[i].push_back(v);
mn[i] = min({mn[i], mn[v], v});
}
}
else if (u < k && v < k) {
if (u < v) return 0;
else return cycle = 1;
}
else if (u < k) {
dfs(u, v);
}
else {
// v < k
mn[u] = min({mn[u], mn[v], v});
}
for (int i = 0; i < k; i++) {
if (mn[i] <= i) {
cycle = 1;
break;
}
}
return cycle;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Incorrect |
1 ms |
2648 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Incorrect |
1 ms |
2648 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Incorrect |
1 ms |
2648 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
1 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2648 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 KB |
Output is correct |
10 |
Correct |
1 ms |
2648 KB |
Output is correct |
11 |
Incorrect |
1 ms |
2648 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |