# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
575931 | SHZhang | 게임 (APIO22_game) | C++17 | 1293 ms | 3960 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <queue>
#include <vector>
using namespace std;
vector<int> graph[30005];
vector<int> rgraph[30005];
int n, k;
int first_go[30005], last_come[30005];
int finish = 0;
queue<int> que;
bool inque[30005];
void push_queue(int x)
{
if (!inque[x]) {
que.push(x); inque[x] = true;
}
}
int pop_queue()
{
int res = que.front(); que.pop();
inque[res] = false;
return res;
}
void init(int N, int K) {
n = N; k = K;
for (int i = 0; i < n; i++) {
first_go[i] = n;
last_come[i] = -1;
}
for (int i = 0; i + 1 < k; i++) {
graph[i].push_back(i+1);
rgraph[i+1].push_back(i);
}
for (int i = 0; i < k; i++) {
first_go[i] = last_come[i] = i;
}
}
int add_teleporter(int u, int v) {
if (v <= u && u < k) return 1;
graph[u].push_back(v);
rgraph[v].push_back(u);
push_queue(u);
push_queue(v);
while (!que.empty()) {
int node = pop_queue();
int old_first_go = first_go[node];
for (int i = 0; i < graph[node].size(); i++) {
int nxt = graph[node][i];
first_go[node] = min(first_go[node], first_go[nxt]);
}
if (old_first_go != first_go[node]) {
for (int i = 0; i < rgraph[node].size(); i++) {
int nxt = rgraph[node][i];
push_queue(nxt);
}
}
int old_last_come = last_come[node];
for (int i = 0; i < rgraph[node].size(); i++) {
int nxt = rgraph[node][i];
last_come[node] = max(last_come[node], last_come[nxt]);
}
if (old_last_come != last_come[node]) {
for (int i = 0; i < graph[node].size(); i++) {
int nxt = graph[node][i];
push_queue(nxt);
}
}
if (node >= k && first_go[node] <= last_come[node]) finish = 1;
}
return finish;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |