답안 #587194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587194 2022-07-01T13:10:08 Z maomao90 게임 (APIO22_game) C++17
100 / 100
1527 ms 107492 KB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;
 
#define REP(i, j, k) for (int i = (j); i < (k); i++)
#define RREP(i, j, k) for (int i = (j); i >= (k); i--)
 
template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}
 
typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;
 
#ifndef DEBUG
#define cerr if (0) cerr
#endif
 
const int MAXN = 300005;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;
 
int n, k;
vi adj[MAXN], radj[MAXN];
int lft[MAXN], rht[MAXN];
bool ans;
 
void init(int N, int K) {
    n = N; k = K;
    n++; k++;
    REP (i, 0, k) {
        lft[i] = i; rht[i] = i + 1;
    }
    REP (i, k, n) {
        lft[i] = 0; rht[i] = k;
    }
}

void propo(int u);

void fix(int u, int v) {
    if (rht[u] <= lft[v]) {
        return;
    }
    if (rht[v] <= lft[u]) {
        ans = 1;
        return;
    }
    if (lft[u] == lft[v] && rht[u] == rht[v]) {
        return;
    }
    int um = lft[u] + rht[u] >> 1, vm = lft[v] + rht[v] >> 1;
    if (um >= rht[v]) {
        rht[u] = um;
        propo(u);
    } else if (vm <= lft[u]) {
        lft[v] = vm;
        propo(v);
    }
}

void propo(int u) {
    for (int v : radj[u]) {
        fix(v, u);
    }
    for (int v : adj[u]) {
        fix(u, v);
    }
}
 
int add_teleporter(int u, int v) {
    u++; v++;
    if (v < k) {
        v--;
    }
    adj[u].pb(v);
    radj[v].pb(u);
    fix(u, v);
    return ans;
}

Compilation message

game.cpp: In function 'void fix(int, int)':
game.cpp:63:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |     int um = lft[u] + rht[u] >> 1, vm = lft[v] + rht[v] >> 1;
      |              ~~~~~~~^~~~~~~~
game.cpp:63:48: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |     int um = lft[u] + rht[u] >> 1, vm = lft[v] + rht[v] >> 1;
      |                                         ~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 8 ms 14396 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 8 ms 14396 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 10 ms 14288 KB Output is correct
13 Correct 9 ms 14276 KB Output is correct
14 Correct 8 ms 14292 KB Output is correct
15 Correct 8 ms 14292 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 10 ms 14416 KB Output is correct
19 Correct 8 ms 14404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 8 ms 14396 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 10 ms 14288 KB Output is correct
13 Correct 9 ms 14276 KB Output is correct
14 Correct 8 ms 14292 KB Output is correct
15 Correct 8 ms 14292 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 10 ms 14416 KB Output is correct
19 Correct 8 ms 14404 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14336 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 11 ms 14416 KB Output is correct
24 Correct 11 ms 14556 KB Output is correct
25 Correct 11 ms 14544 KB Output is correct
26 Correct 12 ms 14472 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14544 KB Output is correct
29 Correct 9 ms 14544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 8 ms 14396 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 10 ms 14288 KB Output is correct
13 Correct 9 ms 14276 KB Output is correct
14 Correct 8 ms 14292 KB Output is correct
15 Correct 8 ms 14292 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 10 ms 14416 KB Output is correct
19 Correct 8 ms 14404 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14336 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 11 ms 14416 KB Output is correct
24 Correct 11 ms 14556 KB Output is correct
25 Correct 11 ms 14544 KB Output is correct
26 Correct 12 ms 14472 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14544 KB Output is correct
29 Correct 9 ms 14544 KB Output is correct
30 Correct 26 ms 15740 KB Output is correct
31 Correct 13 ms 14928 KB Output is correct
32 Correct 29 ms 19236 KB Output is correct
33 Correct 33 ms 16436 KB Output is correct
34 Correct 47 ms 19108 KB Output is correct
35 Correct 39 ms 19272 KB Output is correct
36 Correct 52 ms 16424 KB Output is correct
37 Correct 38 ms 16436 KB Output is correct
38 Correct 32 ms 16196 KB Output is correct
39 Correct 46 ms 16260 KB Output is correct
40 Correct 51 ms 19120 KB Output is correct
41 Correct 46 ms 18088 KB Output is correct
42 Correct 43 ms 16668 KB Output is correct
43 Correct 46 ms 17224 KB Output is correct
44 Correct 58 ms 17388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 8 ms 14396 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 9 ms 14288 KB Output is correct
9 Correct 8 ms 14288 KB Output is correct
10 Correct 9 ms 14288 KB Output is correct
11 Correct 8 ms 14288 KB Output is correct
12 Correct 10 ms 14288 KB Output is correct
13 Correct 9 ms 14276 KB Output is correct
14 Correct 8 ms 14292 KB Output is correct
15 Correct 8 ms 14292 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 10 ms 14416 KB Output is correct
19 Correct 8 ms 14404 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14336 KB Output is correct
22 Correct 9 ms 14416 KB Output is correct
23 Correct 11 ms 14416 KB Output is correct
24 Correct 11 ms 14556 KB Output is correct
25 Correct 11 ms 14544 KB Output is correct
26 Correct 12 ms 14472 KB Output is correct
27 Correct 10 ms 14416 KB Output is correct
28 Correct 9 ms 14544 KB Output is correct
29 Correct 9 ms 14544 KB Output is correct
30 Correct 26 ms 15740 KB Output is correct
31 Correct 13 ms 14928 KB Output is correct
32 Correct 29 ms 19236 KB Output is correct
33 Correct 33 ms 16436 KB Output is correct
34 Correct 47 ms 19108 KB Output is correct
35 Correct 39 ms 19272 KB Output is correct
36 Correct 52 ms 16424 KB Output is correct
37 Correct 38 ms 16436 KB Output is correct
38 Correct 32 ms 16196 KB Output is correct
39 Correct 46 ms 16260 KB Output is correct
40 Correct 51 ms 19120 KB Output is correct
41 Correct 46 ms 18088 KB Output is correct
42 Correct 43 ms 16668 KB Output is correct
43 Correct 46 ms 17224 KB Output is correct
44 Correct 58 ms 17388 KB Output is correct
45 Correct 255 ms 28092 KB Output is correct
46 Correct 15 ms 17132 KB Output is correct
47 Correct 18 ms 17076 KB Output is correct
48 Correct 402 ms 41516 KB Output is correct
49 Correct 402 ms 35536 KB Output is correct
50 Correct 741 ms 52536 KB Output is correct
51 Correct 904 ms 66660 KB Output is correct
52 Correct 689 ms 35396 KB Output is correct
53 Correct 831 ms 35656 KB Output is correct
54 Correct 990 ms 35712 KB Output is correct
55 Correct 1098 ms 36004 KB Output is correct
56 Correct 1273 ms 36000 KB Output is correct
57 Correct 492 ms 29496 KB Output is correct
58 Correct 532 ms 29444 KB Output is correct
59 Correct 517 ms 29696 KB Output is correct
60 Correct 542 ms 29560 KB Output is correct
61 Correct 607 ms 30004 KB Output is correct
62 Correct 396 ms 65336 KB Output is correct
63 Correct 316 ms 61932 KB Output is correct
64 Correct 963 ms 107492 KB Output is correct
65 Correct 560 ms 43808 KB Output is correct
66 Correct 423 ms 41376 KB Output is correct
67 Correct 923 ms 49560 KB Output is correct
68 Correct 215 ms 26316 KB Output is correct
69 Correct 63 ms 20140 KB Output is correct
70 Correct 822 ms 56424 KB Output is correct
71 Correct 322 ms 29040 KB Output is correct
72 Correct 238 ms 24828 KB Output is correct
73 Correct 741 ms 44388 KB Output is correct
74 Correct 1399 ms 35776 KB Output is correct
75 Correct 1283 ms 42868 KB Output is correct
76 Correct 1527 ms 49696 KB Output is correct