#include "werewolf.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef vector<int> vi;
const int N=(1<<18);
int r[N];
vector<int> edg[N];
vector<int> E[N], E2[N];
int find(int v){
if(r[v]==v)return v;
return r[v]=find(r[v]);
}
std::vector<int> check_validity(int n, vi X, vi Y,
vi S, vi T,
vi L, vi R) {
iota(r, r+N, 0);
int m=X.size(), q = S.size();
for(int i=0; i<m; i++){
edg[X[i]].pb(Y[i]);
edg[Y[i]].pb(X[i]);
}
vector<pair<int, int> > Q;
for(int i=0; i<q; i++){
Q.push_back({R[i], i});
}
sort(Q.begin(), Q.end());
int wsk=0;
for(int i=0; i<n; i++){
r[i]=i;
for(int j:edg[i]){
if(j<i){
int v=find(j);
if(i!=v){
r[v]=i;
E[i].push_back(v);
}
}
}
while(wsk<q && Q[wsk].st==i){
//cout<<i<<" "<<T[Q[wsk].nd]<<" "<<find(T[Q[wsk].nd])<<"\n";
T[Q[wsk].nd]=find(T[Q[wsk].nd]);
wsk++;
}
}
//cout<<wsk<<"\n";
iota(r, r+N, 0);
wsk=0;
Q.clear();
for(int i=0; i<q; i++){
Q.push_back({L[i], i});
}
sort(Q.begin(), Q.end());
reverse(Q.begin(), Q.end());
for(int i=n-1; i>=0; i--){
while(wsk<q && Q[wsk].st==i){
S[Q[wsk].st]=find(S[Q[wsk].st]);
wsk++;
}
for(int j:edg[i]){
if(j>i){
int v=find(j);
if(i!=v){
r[v]=i;
E[i].push_back(v);
}
}
}
}
//cout<<wsk<<"a\n";
std::vector<int> A(q);
for (int i = 0; i < q; ++i){
//cout<<i<<" "<<S[i]<<" "<<T[i]<<"\n";
A[i]=(S[i]<=T[i]);
}
return A;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
19788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
19788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
378 ms |
52448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
19788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |