#include <bits/stdc++.h>
//#include "decoder.h"
//#include "decoderlib.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()
using namespace std;
const long long INF = 1e9+5e8;
const int MX=100005;
int n,node=-1;
int par[MX];
int t[MX],cur=1,res;
int up[MX];
int lvl[MX];
vector<int> adj[MX];
void Init(int N_) {
MEM(up,-1);
n = N_;
for(int i=0;i<n;i++){
par[i]=i;
t[i]=1;
lvl[i]=0;
}
res=n;
}
int DSU(int x){
if(x==par[x])R x;
else{
int z=DSU(par[x]);
lvl[x]+=lvl[par[x]];
par[x]=z;
}
R par[x];
}
void check(){
if(res==1){
for(int i=0;i<n;i++)
if(t[i]==cur)
node=i;
}
}
void ADD(int A){
if(adj[A].SI==3){
res=(t[A]==cur);
cur++;
t[A]++;
for(auto i : adj[A]){
t[i]++;
res+=(t[i]==cur);
}
}
if(adj[A].SI>3){
res=(t[A]==cur);
cur++;
t[A]++;
}
check();
}
void getup(int A,int B){
res=0;
if(lvl[A]<lvl[B])swap(A,B);
W(lvl[A]>lvl[B]){
res+=(t[A]==cur);
t[A]++;
A=up[A];
}
W(A!=B){
res+=(t[A]==cur);
t[A]++;
A=up[A];
res+=(t[B]==cur);
t[B]++;
B=up[B];
}
res+=(t[A]==cur);
t[A]++;
cur++;
}
void Link(int A, int B) {
if(res==0)R;
adj[A].pb(B);
adj[B].pb(A);
ADD(A);
ADD(B);
if(DSU(A)==DSU(B)){
if(1){
getup(A,B);
}
else{
}
}
else{
up[A]=B;
}
par[DSU(A)]=DSU(B);
lvl[A]=lvl[B]+1;
}
int CountCritical() {
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3064 KB |
Output is correct |
2 |
Correct |
13 ms |
3444 KB |
Output is correct |
3 |
Correct |
39 ms |
3492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
3492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
8580 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3064 KB |
Output is correct |
2 |
Correct |
13 ms |
3444 KB |
Output is correct |
3 |
Correct |
39 ms |
3492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
3492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3064 KB |
Output is correct |
2 |
Correct |
13 ms |
3444 KB |
Output is correct |
3 |
Correct |
39 ms |
3492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
3492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3064 KB |
Output is correct |
2 |
Correct |
13 ms |
3444 KB |
Output is correct |
3 |
Correct |
39 ms |
3492 KB |
Output is correct |
4 |
Incorrect |
4 ms |
3492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |