제출 #1026764

#제출 시각아이디문제언어결과실행 시간메모리
1026764dozer게임 (IOI14_game)C++14
42 / 100
1050 ms3152 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...