제출 #429207

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
4292072021-06-15 18:55:40CrouchingDragonWerewolf (IOI18_werewolf)C++17
100 / 100
1064 ms87480 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
vi check_validity(int N, vi X, vi Y, vi S, vi E, vi L, vi R) {
int M = (int)size(X), Q = (int)size(S);
vector<vector<int>> left(N), right(N);
for (int j = 0; j < M; ++j) {
int u = X[j], v = Y[j];
if (u > v) swap(u, v);
left[v].push_back(u);
right[u].push_back(v);
}
vector<int> pl(N, N), pr(N, -1), p(N);
auto find = [&](auto& self, int u, int lb, int ub) -> int {
return p[u] < lb || ub < p[u] ? u : p[u] = self(self, p[u], lb, ub);
};
fill(begin(p), end(p), N);
for (int u = 0; u < N; ++u) {
for (auto v : left[u]) {
v = find(find, v, 0, N - 1);
if (v != u) p[v] = pl[v] = u;
}
}
fill(begin(p), end(p), -1);
for (int u = N - 1; u >= 0; --u) {
for (auto v : right[u]) {
v = find(find, v, 0, N - 1);
if (v != u) p[v] = pr[v] = u;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...