제출 #1339776

#제출 시각아이디문제언어결과실행 시간메모리
1339776icebearGame (APIO22_game)C++20
30 / 100
673 ms3548 KiB
/* AUTHOR: TUAN ANH - BUI */
// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

template<class X, class Y>
    bool minimize(X &x, const Y &y) {
        if (x > y) return x = y, true;
        return false;
    }

template<class X, class Y>
    bool maximize(X &x, const Y &y) {
        if (x < y) return x = y, true;
        return false;
    }

#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebear"
/*END OF TEMPLATE. ICEBEAR AND THE CAT WILL WIN TST26 */

const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 27092008;
const ll INF  = (ll)1e18 + 27092008;
const int N = 3e5 + 5;
int n, k;
vector<int> G[N];
int go[N];

bool update(int u) {
    for(int v : G[u]) {
        if (v <= go[u]) return true;
        else if (v >= k && maximize(go[v], go[u]) && update(v)) return true;
    }
    return false;
}

void init(int N, int K) {
    n = N; k = K;
    REP(i, K - 1) G[i].pb(i + 1);
    REP(i, N) go[i] = -1;
    REP(i, K) go[i] = i;
}

int add_teleporter(int u, int v) {
    if (u == v) return v < k;
    G[u].pb(v);
    if (maximize(go[v], go[u])) return update(v);
    return false;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...