답안 #710252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710252 2023-03-15T06:08:29 Z Astrayt 게임 (APIO22_game) C++17
30 / 100
4000 ms 10304 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005

int N, K, good = 0, t = 1;
vector<int> in, low, scc, stk, adj[maxn];

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

void dfs(int u){
    in[u] = low[u] = t++;
    stk.pb(u);
    for(int v:adj[u]){
        if(!in[v]){
            dfs(v);
            low[u] = min(low[v], low[u]);
        }else if(!scc[v]){
            low[u] = min(in[v], low[u]);
        }
    }
    if(low[u] >= in[u]){
        int cur = stk.back(), cnt = 0, cnt2 = 0;
        do{
            scc[cur] = 1;
            cnt += (cur < K);
            cnt2++;
            cur = stk.back(), stk.pop_back();
        }while(stk.size() && cur != u);
        if(!scc[u]){
            scc[cur] = 1;
            cnt += (cur < K);
            cnt2++;
        }
        if(cnt && cnt2 > 1) good = 1;
    }
}

int add_teleporter(int u, int v){
    if(u == v){
        if(u < K) return 1;
        else return 0;
    }
    adj[u].pb(v);
    good = 0, t = 1;
    in.assign(N, 0), low.assign(N, 0), scc.assign(N, 0);
    dfs(0);
    if(good) return 1;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 5 ms 7248 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 6 ms 7348 KB Output is correct
7 Correct 5 ms 7344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 5 ms 7248 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 6 ms 7348 KB Output is correct
7 Correct 5 ms 7344 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 6 ms 7248 KB Output is correct
14 Correct 5 ms 7248 KB Output is correct
15 Correct 5 ms 7248 KB Output is correct
16 Correct 6 ms 7248 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 6 ms 7300 KB Output is correct
19 Correct 4 ms 7340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 5 ms 7248 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 6 ms 7348 KB Output is correct
7 Correct 5 ms 7344 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 6 ms 7248 KB Output is correct
14 Correct 5 ms 7248 KB Output is correct
15 Correct 5 ms 7248 KB Output is correct
16 Correct 6 ms 7248 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 6 ms 7300 KB Output is correct
19 Correct 4 ms 7340 KB Output is correct
20 Correct 8 ms 7248 KB Output is correct
21 Correct 6 ms 7360 KB Output is correct
22 Correct 8 ms 7368 KB Output is correct
23 Correct 7 ms 7376 KB Output is correct
24 Correct 25 ms 7416 KB Output is correct
25 Correct 83 ms 7384 KB Output is correct
26 Correct 105 ms 7508 KB Output is correct
27 Correct 128 ms 7404 KB Output is correct
28 Correct 66 ms 7396 KB Output is correct
29 Correct 83 ms 7528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 5 ms 7248 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 6 ms 7348 KB Output is correct
7 Correct 5 ms 7344 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 6 ms 7248 KB Output is correct
14 Correct 5 ms 7248 KB Output is correct
15 Correct 5 ms 7248 KB Output is correct
16 Correct 6 ms 7248 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 6 ms 7300 KB Output is correct
19 Correct 4 ms 7340 KB Output is correct
20 Correct 8 ms 7248 KB Output is correct
21 Correct 6 ms 7360 KB Output is correct
22 Correct 8 ms 7368 KB Output is correct
23 Correct 7 ms 7376 KB Output is correct
24 Correct 25 ms 7416 KB Output is correct
25 Correct 83 ms 7384 KB Output is correct
26 Correct 105 ms 7508 KB Output is correct
27 Correct 128 ms 7404 KB Output is correct
28 Correct 66 ms 7396 KB Output is correct
29 Correct 83 ms 7528 KB Output is correct
30 Correct 2244 ms 8360 KB Output is correct
31 Correct 667 ms 7940 KB Output is correct
32 Correct 2017 ms 9444 KB Output is correct
33 Correct 1908 ms 8504 KB Output is correct
34 Execution timed out 4014 ms 10304 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7248 KB Output is correct
2 Correct 5 ms 7248 KB Output is correct
3 Correct 5 ms 7248 KB Output is correct
4 Correct 5 ms 7248 KB Output is correct
5 Correct 6 ms 7248 KB Output is correct
6 Correct 6 ms 7348 KB Output is correct
7 Correct 5 ms 7344 KB Output is correct
8 Correct 4 ms 7248 KB Output is correct
9 Correct 4 ms 7248 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7248 KB Output is correct
12 Correct 4 ms 7248 KB Output is correct
13 Correct 6 ms 7248 KB Output is correct
14 Correct 5 ms 7248 KB Output is correct
15 Correct 5 ms 7248 KB Output is correct
16 Correct 6 ms 7248 KB Output is correct
17 Correct 6 ms 7248 KB Output is correct
18 Correct 6 ms 7300 KB Output is correct
19 Correct 4 ms 7340 KB Output is correct
20 Correct 8 ms 7248 KB Output is correct
21 Correct 6 ms 7360 KB Output is correct
22 Correct 8 ms 7368 KB Output is correct
23 Correct 7 ms 7376 KB Output is correct
24 Correct 25 ms 7416 KB Output is correct
25 Correct 83 ms 7384 KB Output is correct
26 Correct 105 ms 7508 KB Output is correct
27 Correct 128 ms 7404 KB Output is correct
28 Correct 66 ms 7396 KB Output is correct
29 Correct 83 ms 7528 KB Output is correct
30 Correct 2244 ms 8360 KB Output is correct
31 Correct 667 ms 7940 KB Output is correct
32 Correct 2017 ms 9444 KB Output is correct
33 Correct 1908 ms 8504 KB Output is correct
34 Execution timed out 4014 ms 10304 KB Time limit exceeded
35 Halted 0 ms 0 KB -