#include <bits/stdc++.h>
using namespace std;
int N;
int ans;
int cnt[1000001] = {0};
vector<int> prospects;
void Init(int N_) {
N = N_;
ans=N;
}
void Link(int A, int B) {
if(prospects.size()==0){
cnt[A]++;
cnt[B]++;
if(max(cnt[A],cnt[B])>2){
ans=0;
if(cnt[A]>2){
prospects.push_back(A);
ans++;
}
if(cnt[B]>2){
prospects.push_back(B);
ans++;
}
}
}else{
if(ans==0)return;
cnt[A]++;
cnt[B]++;
vector<int> sus,not_sus;
for(int v : prospects){
if(v==A||v==B)sus.push_back(v);
else not_sus.push_back(v);
}
if(sus.size()==0){
if(max(cnt[A],cnt[B])>2)ans=0;
return;
}else{
swap(sus,prospects);
ans=1;
}
}
}
int CountCritical() {
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
9456 KB |
Output is correct |
2 |
Correct |
106 ms |
14164 KB |
Output is correct |
3 |
Correct |
103 ms |
16976 KB |
Output is correct |
4 |
Incorrect |
122 ms |
17744 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |