답안 #1113557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113557 2024-11-16T17:58:51 Z _8_8_ 게임 (APIO22_game) C++17
2 / 100
11 ms 14584 KB
#include "game.h"
 
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3e5 + 12;

int n, k, s[N], t[N];
vector<int> g[N], gr[N];
void init(int nn, int kk) {
    n = nn;
    k = kk;
    for(int i = k; i < n; i++) {
        s[i] = -1, t[i] = k;
    }
    for(int i = 0; i < k; ++i) {
        s[i] = t[i] = i;
    }
}
int vis[N], timer;
void dfs(int v, int val) {
    vis[v] = timer;
    s[v] = max(s[v], val);
    for(int to:g[v]) if(vis[to] != timer && s[to] < val) {
        dfs(to, val);
    }
}
void dfs1(int v, int val) {
    t[v] = min(t[v], val);
    for(int to:gr[v]) if(vis[to] != timer && t[to] > val) {
        dfs1(to, val);
    }
}
bool cyc = 0;
int add_teleporter(int u, int v) {
    if(max(u, v) < k) {
        if(u >= v) cyc = 1;
    }
    if(cyc) return 1;
    if(s[u] <= s[v] && t[u] <= t[v]) return 0;
    g[u].push_back(v);
    gr[v].push_back(u);
    timer++;
    dfs(v, s[u]);
    timer++;
    dfs1(u, t[v]);
    vis[v] = timer;
    for(int i = k; i < n; i++) {
        if(s[i] >= t[i]) {
            cyc = 1;
            return 1;
        }
    }
    return 0;
}  
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 9 ms 14356 KB Output is correct
3 Correct 11 ms 14416 KB Output is correct
4 Correct 10 ms 14416 KB Output is correct
5 Correct 10 ms 14456 KB Output is correct
6 Correct 10 ms 14584 KB Output is correct
7 Correct 10 ms 14416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 9 ms 14356 KB Output is correct
3 Correct 11 ms 14416 KB Output is correct
4 Correct 10 ms 14416 KB Output is correct
5 Correct 10 ms 14456 KB Output is correct
6 Correct 10 ms 14584 KB Output is correct
7 Correct 10 ms 14416 KB Output is correct
8 Correct 9 ms 14416 KB Output is correct
9 Correct 9 ms 14408 KB Output is correct
10 Correct 10 ms 14416 KB Output is correct
11 Incorrect 10 ms 14416 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 9 ms 14356 KB Output is correct
3 Correct 11 ms 14416 KB Output is correct
4 Correct 10 ms 14416 KB Output is correct
5 Correct 10 ms 14456 KB Output is correct
6 Correct 10 ms 14584 KB Output is correct
7 Correct 10 ms 14416 KB Output is correct
8 Correct 9 ms 14416 KB Output is correct
9 Correct 9 ms 14408 KB Output is correct
10 Correct 10 ms 14416 KB Output is correct
11 Incorrect 10 ms 14416 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 9 ms 14356 KB Output is correct
3 Correct 11 ms 14416 KB Output is correct
4 Correct 10 ms 14416 KB Output is correct
5 Correct 10 ms 14456 KB Output is correct
6 Correct 10 ms 14584 KB Output is correct
7 Correct 10 ms 14416 KB Output is correct
8 Correct 9 ms 14416 KB Output is correct
9 Correct 9 ms 14408 KB Output is correct
10 Correct 10 ms 14416 KB Output is correct
11 Incorrect 10 ms 14416 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 14416 KB Output is correct
2 Correct 9 ms 14356 KB Output is correct
3 Correct 11 ms 14416 KB Output is correct
4 Correct 10 ms 14416 KB Output is correct
5 Correct 10 ms 14456 KB Output is correct
6 Correct 10 ms 14584 KB Output is correct
7 Correct 10 ms 14416 KB Output is correct
8 Correct 9 ms 14416 KB Output is correct
9 Correct 9 ms 14408 KB Output is correct
10 Correct 10 ms 14416 KB Output is correct
11 Incorrect 10 ms 14416 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -