답안 #752619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
752619 2023-06-03T10:15:58 Z Dan4Life 게임 (APIO22_game) C++17
2 / 100
7 ms 9712 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int mxN = (int)2e5+10;
int n, k, sm[mxN], bg[mxN];
vector<int> adj[mxN], radj[mxN];

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

void dfs(int s, int c, vector<int> adj[], bool ok){ 
    if(ok){
        if(c>=k) return;
        if(bg[s]>=c) return;
        bg[s] = c;
    }
    else{
        if(sm[s]<=c) return;
        sm[s] = c;
    }
    for(auto u : adj[s]) dfs(u,c,adj,ok);
}

int add_teleporter(int u, int v) {
    adj[u].pb(v), radj[v].pb(u); 
    if(u>=v and u<k) return 1;
    if(max(u,v)<k) return 0;
    dfs(u, sm[v], radj,0), dfs(v,bg[u], adj,1); 
    return (sm[v]<=bg[u] and bg[u]<k);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 7 ms 9680 KB Output is correct
3 Correct 6 ms 9712 KB Output is correct
4 Correct 5 ms 9592 KB Output is correct
5 Correct 5 ms 9680 KB Output is correct
6 Correct 5 ms 9680 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 7 ms 9680 KB Output is correct
3 Correct 6 ms 9712 KB Output is correct
4 Correct 5 ms 9592 KB Output is correct
5 Correct 5 ms 9680 KB Output is correct
6 Correct 5 ms 9680 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 5 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 5 ms 9680 KB Output is correct
11 Incorrect 5 ms 9680 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 7 ms 9680 KB Output is correct
3 Correct 6 ms 9712 KB Output is correct
4 Correct 5 ms 9592 KB Output is correct
5 Correct 5 ms 9680 KB Output is correct
6 Correct 5 ms 9680 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 5 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 5 ms 9680 KB Output is correct
11 Incorrect 5 ms 9680 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 7 ms 9680 KB Output is correct
3 Correct 6 ms 9712 KB Output is correct
4 Correct 5 ms 9592 KB Output is correct
5 Correct 5 ms 9680 KB Output is correct
6 Correct 5 ms 9680 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 5 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 5 ms 9680 KB Output is correct
11 Incorrect 5 ms 9680 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9680 KB Output is correct
2 Correct 7 ms 9680 KB Output is correct
3 Correct 6 ms 9712 KB Output is correct
4 Correct 5 ms 9592 KB Output is correct
5 Correct 5 ms 9680 KB Output is correct
6 Correct 5 ms 9680 KB Output is correct
7 Correct 6 ms 9680 KB Output is correct
8 Correct 5 ms 9680 KB Output is correct
9 Correct 5 ms 9680 KB Output is correct
10 Correct 5 ms 9680 KB Output is correct
11 Incorrect 5 ms 9680 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -