답안 #816450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
816450 2023-08-09T05:09:39 Z 이동현(#10127) 게임 (APIO22_game) C++17
2 / 100
1 ms 1616 KB
#include "game.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;

int n, k;
vector<int> way[30004], wayb[30004];
int mn[30004], mx[30004];

void init(int N, int K) {
    n = N, k = K;
    assert(n <= 30000 && k <= 1000);
    for(int i = 0; i < k; ++i){
        mn[i] = mx[i] = i;
    }
    for(int i = k; i < n; ++i){
        mn[i] = (int)1e9, mx[i] = -1;
    }
}

int add_teleporter(int u, int v) {
    way[u].push_back(v);
    wayb[v].push_back(u);

    auto dfs1 = [&](auto&&self, int x)->int{
        for(auto&nxt:way[x]){
            int go = 0;
            if(mn[nxt] < mn[x]){
                mn[x] = mn[nxt], go = 1;
            }
            // if(mx[x] > mx[nxt]){
            //     mx[nxt] = mx[x], go = 1;
            // }
            if(go) self(self, nxt);
        }
        return mn[x];
    };
    dfs1(dfs1, u);

    auto dfs2 = [&](auto&&self, int x)->int{
        for(auto&nxt:wayb[x]){
            int go = 0;
            if(mx[nxt] > mx[x]){
                mx[x] = mx[nxt], go = 1;
            }
            // if(mn[x] < mn[nxt]){
            //     mn[nxt] = mn[x], go = 1;
            // }
            if(go) self(self, nxt);
        }
        return mx[x];
    };
    dfs2(dfs2, v);

    return mn[v] <= mx[u];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Incorrect 1 ms 1616 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Incorrect 1 ms 1616 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Incorrect 1 ms 1616 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1616 KB Output is correct
2 Correct 1 ms 1616 KB Output is correct
3 Correct 1 ms 1616 KB Output is correct
4 Correct 1 ms 1616 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1616 KB Output is correct
7 Correct 1 ms 1616 KB Output is correct
8 Correct 1 ms 1616 KB Output is correct
9 Correct 1 ms 1616 KB Output is correct
10 Correct 1 ms 1616 KB Output is correct
11 Incorrect 1 ms 1616 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -