Submission #620062

# Submission time Handle Problem Language Result Execution time Memory
620062 2022-08-02T20:59:28 Z Lobo Game (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;
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -