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>
#include "game.h"
using namespace std;
using ll = long long;
const int mxN = 2e3+10;
int cnt[mxN];
int n, past = 0;
int hasEdge(int u, int v) {
++cnt[u]; ++cnt[v];
if(cnt[u] == n-1 || cnt[v] == n-1) {--past; return 1;}
if((cnt[u] == n-2 || cnt[v] == n-2) && past) {
if(cnt[u] == n-2) cnt[u] = n;
else cnt[v] = n;
return 1;
}
if(cnt[u] == n-2)++past;
if(cnt[v] == n-2)++past;
return 0;
}
void initialize(int N) {
n = N;
}
/*
int main()
{
initialize(4);
cout << hasEdge(0, 3) << hasEdge(1, 0) << hasEdge(0, 2) << hasEdge(3, 1);
cout << hasEdge(1, 2) << hasEdge(2, 3);
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |