답안 #1026764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026764 2024-07-18T10:49:45 Z dozer 게임 (IOI14_game) C++14
42 / 100
1000 ms 3152 KB
#include "game.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt","w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define LL node * 2
#define RR node * 2
#define mid (l + r) / 2
#define ll long long
#define MAXN 1600

const int modulo = 1e9 + 7;
const ll INF = 2e18 +7;


int N;
bitset<MAXN> adj[MAXN];
set<int> child[MAXN];
int par[MAXN], tin[MAXN], tout[MAXN], cntr, sz[MAXN];

void initialize(int n) {
    N = n;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++) adj[i].set(j, 1);
    }
    for (int i = 1; i < n; i++){
        child[0].insert(i);
        child[i].insert(0);
        par[i] = 0;
    }
    par[0] = -1;
}


void dfs(int node, int root){
   // cout<<node<<sp<<root<<endl;
    par[node] = root;
    tin[node] = ++cntr;
    sz[node] = 1;
    for (auto  i : child[node]){
        if (i == root) continue;
        dfs(i, node);
        sz[node] += sz[i];
    }
    tout[node] = cntr;
}

void sub(int node, int root, bitset<MAXN> &b){
    b |= adj[node];
    for (auto i : child[node]){
        if (i == root) continue;
        sub(i, node, b);
    }
}


int hasEdge(int u, int v) {
    cntr = 0;
    dfs(v, -1);
    adj[u].set(v, 0);
    adj[v].set(u, 0);
    if (par[u] != v){
        return 0;
    }

    child[u].erase(v);
    child[v].erase(u);

    

    bitset<MAXN> to;
    to.reset();
    sub(u, v, to);
    int parr = -1;
    for (int i = 0; i < N; i++){
        if (tin[i] >= tin[u] && tout[i] <= tout[u]) continue;
        if (to[i] == 1){
            parr = i;
            break;
        }
    }

    if (parr == -1){
        adj[u][v] = 1;
        adj[v][u] = 1;
        child[u].insert(v);
        child[v].insert(u);
        return 1;  
    }


    int c = -1;
    for (int i = 0; i < N; i++){
        if (tin[i] >= tin[u] && tout[i] <= tout[u] && adj[i][parr] == 1){
            c = i;
            break;
        }
    }


    child[parr].insert(c);
    child[c].insert(parr);
    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2408 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 0 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 4 ms 2396 KB Output is correct
35 Correct 4 ms 2392 KB Output is correct
36 Correct 4 ms 2396 KB Output is correct
37 Correct 4 ms 2396 KB Output is correct
38 Correct 5 ms 2396 KB Output is correct
39 Correct 4 ms 2616 KB Output is correct
40 Correct 6 ms 2392 KB Output is correct
41 Correct 4 ms 2396 KB Output is correct
42 Correct 4 ms 2396 KB Output is correct
43 Correct 5 ms 2392 KB Output is correct
44 Correct 3 ms 2396 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 4 ms 2392 KB Output is correct
47 Correct 4 ms 2396 KB Output is correct
48 Correct 3 ms 2396 KB Output is correct
49 Correct 4 ms 2396 KB Output is correct
50 Correct 4 ms 2392 KB Output is correct
51 Correct 4 ms 2392 KB Output is correct
52 Correct 4 ms 2392 KB Output is correct
53 Correct 6 ms 2396 KB Output is correct
54 Correct 6 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 4 ms 2392 KB Output is correct
35 Correct 5 ms 2396 KB Output is correct
36 Correct 4 ms 2396 KB Output is correct
37 Correct 4 ms 2612 KB Output is correct
38 Correct 4 ms 2396 KB Output is correct
39 Correct 4 ms 2396 KB Output is correct
40 Correct 4 ms 2396 KB Output is correct
41 Correct 4 ms 2396 KB Output is correct
42 Correct 4 ms 2396 KB Output is correct
43 Correct 5 ms 2396 KB Output is correct
44 Correct 3 ms 2396 KB Output is correct
45 Correct 3 ms 2392 KB Output is correct
46 Correct 4 ms 2392 KB Output is correct
47 Correct 3 ms 2396 KB Output is correct
48 Correct 4 ms 2396 KB Output is correct
49 Correct 3 ms 2616 KB Output is correct
50 Correct 4 ms 2392 KB Output is correct
51 Correct 4 ms 2396 KB Output is correct
52 Correct 4 ms 2396 KB Output is correct
53 Correct 4 ms 2616 KB Output is correct
54 Correct 4 ms 2624 KB Output is correct
55 Correct 620 ms 2936 KB Output is correct
56 Correct 632 ms 2896 KB Output is correct
57 Correct 665 ms 2936 KB Output is correct
58 Correct 601 ms 3152 KB Output is correct
59 Correct 600 ms 2896 KB Output is correct
60 Correct 606 ms 2896 KB Output is correct
61 Correct 687 ms 2896 KB Output is correct
62 Correct 638 ms 2940 KB Output is correct
63 Correct 663 ms 2896 KB Output is correct
64 Execution timed out 1050 ms 2652 KB Time limit exceeded
65 Halted 0 ms 0 KB -