Submission #1038055

#TimeUsernameProblemLanguageResultExecution timeMemory
1038055RecursiveCoWerewolf (IOI18_werewolf)C++17
15 / 100
365 ms20368 KiB
#include <bits/stdc++.h> using namespace std; #define in(i) cin >> i #define out(o) cout << o vector<int> parent; vector<int> sz; int find(int v) { if (v == parent[v]) return v; return parent[v] = find(parent[v]); } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (sz[a] > sz[b]) swap(a, b); parent[a] = b; sz[b] += sz[a]; } vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R) { int M = X.size(); // = Y.size() int Q = S.size(); // = E.size() = L.size() = R.size() parent.resize(N); sz.resize(N, 1); vector<int> ans(Q); if (N <= 3000 && M <= 6000 && Q <= 3000) { // S1, S2 for (int i = 0; i < Q; i++) { int l = L[i]; int r = R[i]; int s = S[i]; int e = E[i]; for (int j = 0; j < N; j++) parent[j] = j, sz[j] = 1; for (int j = 0; j < M; j++) { int x = X[j]; int y = Y[j]; if (l <= min(x, y)) unite(x, y); } vector<int> works(N, 0); for (int j = 0; j < N; j++) if (find(s) == find(j)) works[j]++; for (int j = 0; j < N; j++) parent[j] = j, sz[j] = 1; for (int j = 0; j < M; j++) { int x = X[j]; int y = Y[j]; if (r >= max(x, y)) unite(x, y); } for (int j = 0; j < N; j++) if (find(e) == find(j)) works[j]++; ans[i] = +(*max_element(works.begin(), works.end()) == 2); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...