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;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 1e3+100;
int N, deg[MAXN], cnt[MAXN];
void initialize(int n){
N = n;
fill(deg, deg + N, N - 1);
cnt[N - 1] = N;
}
int hasEdge(int u, int v){
cnt[deg[u]]--, cnt[deg[v]]--;
deg[u]--, deg[v]--;
cnt[deg[u]]++, cnt[deg[v]]++;
if(deg[u] == 0 || deg[v] == 0 || (deg[u] == 1 && cnt[deg[u]] >= 3) || (deg[v] == 1 && cnt[deg[v]] >= 3)){
cnt[deg[u]]--, cnt[deg[v]]--;
deg[u]++, deg[v]++;
cnt[deg[u]]++, cnt[deg[v]]++;
return 1;
}
if(deg[u] == deg[v] && deg[u] == 1 && cnt[deg[u]] >= 2){
cnt[deg[u]]--, cnt[deg[v]]--;
deg[u]++, deg[v]++;
cnt[deg[u]]++, cnt[deg[v]]++;
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |