This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |