Submission #257405

#TimeUsernameProblemLanguageResultExecution timeMemory
257405islingrAmusement Park (JOI17_amusement_park)C++17
81 / 100
32 ms4376 KiB
#include "Joi.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define all(x) begin(x), end(x) using ll = long long; namespace { const int N = 1 << 14, B = 60; int nxt[N]; int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; } bool unite(int u, int v) { u = head(u); v = head(v); if (u == v) return 0; nxt[u] = v; return 1; } vector<int> g[N]; int timer = 0; ll x; void dfs(int u, int p) { MessageBoard(u, x >> timer & 1); if (++timer == B) timer = 0; for (int v : g[u]) if (v != p) dfs(v, u); } } void Joi(int n, int m, int a[], int b[], ll X, int t) { rep(u, 0, n) nxt[u] = u; rep(e, 0, m) { if (unite(a[e], b[e])) { g[a[e]].push_back(b[e]); g[b[e]].push_back(a[e]); } } x = X; dfs(0, -1); }
#include "Ioi.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define all(x) begin(x), end(x) using ll = int64_t; namespace { const int N = 1 << 14, B = 60; int nxt[N]; int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; } bool unite(int u, int v) { u = head(u); v = head(v); if (u == v) return 0; nxt[u] = v; return 1; } vector<int> g[N]; bool vis[N]; int p[N], in[N], timer = 0; void init(int u) { in[u] = timer; if (++timer == B) timer = 0; for (int v : g[u]) { g[v].erase(find(all(g[v]), u)); p[v] = u; init(v); } } ll U = (1ll << B) - 1, cur = 0, x = 0; bool dfs(int u, ll z) { vis[u] = true; cur |= 1ll << in[u]; x |= z << in[u]; if (cur == U) return true; for (int v : g[u]) { if (vis[v]) continue; if (dfs(v, Move(v))) return true; Move(u); } return false; } } long long Ioi(int n, int m, int a[], int b[], int P, int V, int T) { rep(u, 0, n) nxt[u] = u; rep(e, 0, m) { if (unite(a[e], b[e])) { g[a[e]].push_back(b[e]); g[b[e]].push_back(a[e]); } } init(0); while (!dfs(P, V)) V = Move(p[P]), P = p[P]; return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...