답안 #620062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
620062 2022-08-02T20:59:28 Z Lobo 게임 (APIO22_game) C++17
0 / 100
215 ms 262144 KB
#include "game.h"
#include<iostream>
#include<vector>
using namespace std;

#define pb push_back

const int maxn = 5e4+10;

int n, k, smx[maxn], smn[maxn];
vector<int> g[maxn], gt[maxn];
int ans = 0;

void dfsmx(int u, int val) {
    if(val <= smx[u]) return;
    smx[u] = val;
    if(u < k && smx[u] > u)
        ans = 1;
    if(u >= k && smx[u] >= smn[u])
        ans = 1;
    // if(smx[u] >= smn[u])
    //     ans = 1;
    for(auto v : g[u]) {
        dfsmx(v,val);
    }
}

void dfsmn(int u, int val) {
    if(val >= smx[u]) return;
    smn[u] = val;
    if(u < k && smx[u] > u)
        ans = 1;
    if(u >= k && smx[u] >= smn[u])
        ans = 1;
    // if(smx[u] >= smn[u])
    //     ans = 1;
    for(auto v : gt[u]) {
        dfsmn(v,val);
    }
}

void init(int N, int K) {
    n = N;
    k = K;
    for(int i = 0; i < k; i++) {
        smn[i] = i;
        smx[i] = i;
    }
    for(int i = k; i < n; i++) {
        smn[i] = n;
        smx[i] = -1;
    }
}

int add_teleporter(int u, int v) {
    g[u].pb(v);
    gt[v].pb(u);
    if(u == v && u < k) return 1;
    dfsmx(v,smx[u]);
    dfsmn(u,smn[v]);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2588 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Runtime error 215 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2588 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Runtime error 215 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2588 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Runtime error 215 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2588 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Runtime error 215 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2588 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Runtime error 215 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -