답안 #741901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741901 2023-05-15T04:25:28 Z t6twotwo 게임 (APIO22_game) C++17
30 / 100
4000 ms 11320 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<vector<bool>> a, b;
vector<vector<int>> adj, jda;
void init(int n, int k) {
    N = n;
    K = k;
    adj.resize(N);
    jda.resize(N);
    a = vector(N, vector<bool>(K));
    b = vector(K, vector<bool>(N));
    for (int i = 0; i + 1 < K; i++) {
        adj[i].push_back(i + 1);
        jda[i + 1].push_back(i);
        for (int j = i + 1; j < K; j++) {
            a[i][j] = 1;
            b[i][j] = 1;
        }
    }
}
int add_teleporter(int u, int v) {
    if (u < K && v < K) {
        return v <= u;
    }
    adj[u].push_back(v);
    jda[v].push_back(u);
    for (int i = 0; i < K; i++) {
        if (b[i][u] || i == u) {
            b[i][v] = 1;
            queue<int> q;
            q.push(v);
            while (!q.empty()) {
                int x = q.front();
                q.pop();
                for (int y : adj[x]) {
                    if (!b[i][y]) {
                        b[i][y] = 1;
                        q.push(y);
                    }
                }
            }
        }
    }
    for (int i = 0; i < K; i++) {
        if (a[v][i] || i == v) {
            a[u][i] = 1;
            queue<int> q;
            q.push(u);
            while (!q.empty()) {
                int x = q.front();
                q.pop();
                for (int y : jda[x]) {
                    if (!a[y][i]) {
                        a[y][i] = 1;
                        q.push(y);
                    }
                }
            }
        }
    }
    for (int i = 0; i < K; i++) {
        for (int j = i; j < K; j++) {
            if (a[j][i]) {
                return 1;
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 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 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 2 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 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 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 2 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 7 ms 464 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 152 ms 596 KB Output is correct
25 Correct 140 ms 532 KB Output is correct
26 Correct 45 ms 488 KB Output is correct
27 Correct 618 ms 744 KB Output is correct
28 Correct 318 ms 596 KB Output is correct
29 Correct 425 ms 584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 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 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 2 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 7 ms 464 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 152 ms 596 KB Output is correct
25 Correct 140 ms 532 KB Output is correct
26 Correct 45 ms 488 KB Output is correct
27 Correct 618 ms 744 KB Output is correct
28 Correct 318 ms 596 KB Output is correct
29 Correct 425 ms 584 KB Output is correct
30 Correct 194 ms 5400 KB Output is correct
31 Execution timed out 4026 ms 11320 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 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 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 2 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 7 ms 464 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 152 ms 596 KB Output is correct
25 Correct 140 ms 532 KB Output is correct
26 Correct 45 ms 488 KB Output is correct
27 Correct 618 ms 744 KB Output is correct
28 Correct 318 ms 596 KB Output is correct
29 Correct 425 ms 584 KB Output is correct
30 Correct 194 ms 5400 KB Output is correct
31 Execution timed out 4026 ms 11320 KB Time limit exceeded
32 Halted 0 ms 0 KB -