답안 #730467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730467 2023-04-26T01:16:49 Z vjudge1 게임 (APIO22_game) C++17
2 / 100
9 ms 14424 KB
#include <bits/stdc++.h>
using namespace std;
#include "game.h"

int N, K;
int l[300000], r[300000];  // max_to, min_from
vector<int> adj[300000], radj[300000];
int last[300000];
int res = 0;

void init(int n, int k) {
        N = n, K = k;
        for (int i = 0; i < K; i++) l[i] = i, r[i] = i + 1;
        for (int i = K; i < N; i++) l[i] = 0, r[i] = K + 1;
        for (int i = 0; i < N; i++) last[i] = __lg(l[i] ^ r[i]);
}

void update(int u) {
        if (res == 1) return;
        if (r[u] <= l[u]) return void(res = 1);
        int cur = __lg(l[u] ^ r[u]);
        if (cur == last[u]) return;
        last[u] = cur;
        for (int v : adj[u]) {
                if (l[v] < l[u]) l[v] = l[u], update(v);
        }
        for (int v : radj[u]) {
                if (r[v] > r[u]) r[v] = r[u], update(v);
        }
}

int add_teleporter(int u, int v) {
        if (v <= u && u < K) return 1;
        if (u == v) return 0;

        adj[u].emplace_back(v);
        radj[v].emplace_back(u);

        int val = u < K ? max(u, l[u]) : l[u];

        if (l[v] < val) l[v] = val, update(v);
        if (r[u] > r[v]) r[u] = r[v], update(u);

        return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14380 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 9 ms 14424 KB Output is correct
4 Correct 7 ms 14352 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14408 KB Output is correct
7 Correct 8 ms 14324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14380 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 9 ms 14424 KB Output is correct
4 Correct 7 ms 14352 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14408 KB Output is correct
7 Correct 8 ms 14324 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Incorrect 9 ms 14416 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14380 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 9 ms 14424 KB Output is correct
4 Correct 7 ms 14352 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14408 KB Output is correct
7 Correct 8 ms 14324 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Incorrect 9 ms 14416 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14380 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 9 ms 14424 KB Output is correct
4 Correct 7 ms 14352 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14408 KB Output is correct
7 Correct 8 ms 14324 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Incorrect 9 ms 14416 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14380 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 9 ms 14424 KB Output is correct
4 Correct 7 ms 14352 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 8 ms 14408 KB Output is correct
7 Correct 8 ms 14324 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 8 ms 14416 KB Output is correct
12 Correct 8 ms 14416 KB Output is correct
13 Incorrect 9 ms 14416 KB Wrong Answer[1]
14 Halted 0 ms 0 KB -