///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define MAXN 1000001
int n,x;
int e[MAXN];
int f[MAXN];
int par[MAXN];
int vis[MAXN];
vector<int> a[MAXN];
void dfs(int v,int u,vector<int>& vec){
vis[v]=1;
vec.append(v);
for(auto& i:a[v])
if(!vis[i])
dfs(i,u,vec);
if(vec.back()!=u) vec.pop_back();
}
int root(int v){
if(par[v]==v) return v;
par[v]=root(par[v]);
return par[v];
}
void join(int v,int u){
v=root(v);
u=root(u);
par[u]=v;
f[v]+=f[u];
}
bool same(int v,int u){
return (root(v)==root(u));
}
void Init(int u){
n=x=u;
for(int i=0;i<n;i++){
par[i]=i;
e[i]=1;
}
}
void Link(int v, int u){
if(!x) return;
if(!f[root(v)] && same(v,u)){
vector<int> vec;
for(int i=0;i<n;i++) vis[i]=0;
dfs(v,u,vec);
map<int,int> z;
for(auto& i:vec) z[i]=1;
for(int i=x=0;i<n;i++){
if(!z[i]) e[i]=0;
x+=e[i];
}
}
a[v].append(u);
a[u].append(v);
join(v,u);
if(a[v].size()>3){
for(int i=0;i<n;i++)
if(i!=v) e[i]=0;
x=e[v];
}
if(a[u].size()>3){
for(int i=0;i<n;i++)
if(i!=u) e[i]=0;
x=e[u];
}
if(a[v].size()==3){
map<int,int> z;
z[v]=1;
for(auto& i:a[v]) z[i]=1;
for(int i=x=0;i<n;i++){
if(!z[i]) e[i]=0;
x+=e[i];
}
}
if(a[u].size()==3){
map<int,int> z;
z[u]=1;
for(auto& i:a[u]) z[i]=1;
for(int i=x=0;i<n;i++){
if(!z[i]) e[i]=0;
x+=e[i];
}
}
}
int CountCritical(){
return x;;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
31320 KB |
Output is correct |
2 |
Correct |
12 ms |
31576 KB |
Output is correct |
3 |
Correct |
10 ms |
31768 KB |
Output is correct |
4 |
Correct |
11 ms |
31320 KB |
Output is correct |
5 |
Correct |
12 ms |
31744 KB |
Output is correct |
6 |
Correct |
11 ms |
31836 KB |
Output is correct |
7 |
Correct |
9 ms |
31580 KB |
Output is correct |
8 |
Correct |
10 ms |
31576 KB |
Output is correct |
9 |
Correct |
11 ms |
31576 KB |
Output is correct |
10 |
Correct |
14 ms |
31832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
51788 KB |
Output is correct |
2 |
Correct |
804 ms |
88112 KB |
Output is correct |
3 |
Correct |
518 ms |
84964 KB |
Output is correct |
4 |
Correct |
1053 ms |
117816 KB |
Output is correct |
5 |
Correct |
1026 ms |
119280 KB |
Output is correct |
6 |
Correct |
1503 ms |
148824 KB |
Output is correct |
7 |
Correct |
530 ms |
85100 KB |
Output is correct |
8 |
Correct |
1285 ms |
108796 KB |
Output is correct |
9 |
Correct |
1391 ms |
115520 KB |
Output is correct |
10 |
Correct |
886 ms |
116340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
31320 KB |
Output is correct |
2 |
Correct |
12 ms |
31576 KB |
Output is correct |
3 |
Correct |
10 ms |
31768 KB |
Output is correct |
4 |
Correct |
11 ms |
31320 KB |
Output is correct |
5 |
Correct |
12 ms |
31744 KB |
Output is correct |
6 |
Correct |
11 ms |
31836 KB |
Output is correct |
7 |
Correct |
9 ms |
31580 KB |
Output is correct |
8 |
Correct |
10 ms |
31576 KB |
Output is correct |
9 |
Correct |
11 ms |
31576 KB |
Output is correct |
10 |
Correct |
14 ms |
31832 KB |
Output is correct |
11 |
Correct |
13 ms |
31836 KB |
Output is correct |
12 |
Correct |
17 ms |
32140 KB |
Output is correct |
13 |
Correct |
18 ms |
32092 KB |
Output is correct |
14 |
Correct |
2027 ms |
32144 KB |
Output is correct |
15 |
Execution timed out |
4019 ms |
32612 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
31320 KB |
Output is correct |
2 |
Correct |
12 ms |
31576 KB |
Output is correct |
3 |
Correct |
10 ms |
31768 KB |
Output is correct |
4 |
Correct |
11 ms |
31320 KB |
Output is correct |
5 |
Correct |
12 ms |
31744 KB |
Output is correct |
6 |
Correct |
11 ms |
31836 KB |
Output is correct |
7 |
Correct |
9 ms |
31580 KB |
Output is correct |
8 |
Correct |
10 ms |
31576 KB |
Output is correct |
9 |
Correct |
11 ms |
31576 KB |
Output is correct |
10 |
Correct |
14 ms |
31832 KB |
Output is correct |
11 |
Correct |
13 ms |
31836 KB |
Output is correct |
12 |
Correct |
17 ms |
32140 KB |
Output is correct |
13 |
Correct |
18 ms |
32092 KB |
Output is correct |
14 |
Correct |
2027 ms |
32144 KB |
Output is correct |
15 |
Execution timed out |
4019 ms |
32612 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
31320 KB |
Output is correct |
2 |
Correct |
12 ms |
31576 KB |
Output is correct |
3 |
Correct |
10 ms |
31768 KB |
Output is correct |
4 |
Correct |
11 ms |
31320 KB |
Output is correct |
5 |
Correct |
12 ms |
31744 KB |
Output is correct |
6 |
Correct |
11 ms |
31836 KB |
Output is correct |
7 |
Correct |
9 ms |
31580 KB |
Output is correct |
8 |
Correct |
10 ms |
31576 KB |
Output is correct |
9 |
Correct |
11 ms |
31576 KB |
Output is correct |
10 |
Correct |
14 ms |
31832 KB |
Output is correct |
11 |
Correct |
278 ms |
51788 KB |
Output is correct |
12 |
Correct |
804 ms |
88112 KB |
Output is correct |
13 |
Correct |
518 ms |
84964 KB |
Output is correct |
14 |
Correct |
1053 ms |
117816 KB |
Output is correct |
15 |
Correct |
1026 ms |
119280 KB |
Output is correct |
16 |
Correct |
1503 ms |
148824 KB |
Output is correct |
17 |
Correct |
530 ms |
85100 KB |
Output is correct |
18 |
Correct |
1285 ms |
108796 KB |
Output is correct |
19 |
Correct |
1391 ms |
115520 KB |
Output is correct |
20 |
Correct |
886 ms |
116340 KB |
Output is correct |
21 |
Correct |
13 ms |
31836 KB |
Output is correct |
22 |
Correct |
17 ms |
32140 KB |
Output is correct |
23 |
Correct |
18 ms |
32092 KB |
Output is correct |
24 |
Correct |
2027 ms |
32144 KB |
Output is correct |
25 |
Execution timed out |
4019 ms |
32612 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |