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 "game.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;
const int inf = 1e9 + 333;
const ll linf = 1e18 + 333;
const int N = 1500 + 5;
int n, cnt, in[N], query_in[N];
vector < int > v[N];
void initialize(int n) {
:: n = n;
}
int hasEdge(int x, int y) {
if(!cnt) {
cnt = 2;
in[x] = in[y] = 1;
query_in[x] = query_in[y] = 1;
return 1;
}
if(!in[x] and !in[y]) {
v[x].push_back(y);
v[y].push_back(x);
return 0;
}
assert(!in[x] or !in[y]);
if(!in[x])
swap(x, y);
if(query_in[y] == cnt - 1) {
in[y] = 1;
cnt++;
foreach(it, v[y])
query_in[*it]++;
return 1;
}
query_in[y]++;
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... |