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 <bits/stdc++.h>
using namespace std;
int cek[1501][1501], cnt[1501], ls[1501];
void initialize(int n) {
	for(int i=0;i<n;i++) {
		for(int k=0;k<n;k++) {
			cek[i][k] = -1;
		}
		cek[i][i] = 0;
		cnt[i] = n - 1;
		ls[i] = n-1;
	}
}
void upd(int f) {
	while(ls[f] >= 0 && cek[f][ls[f]] != -1) ls[f]--;
	return;
}
int hasEdge(int u, int v) {
    if(cek[u][v] != -1) return cek[u][v];
    
    if(cnt[v] == 1) swap(u, v);
    if(cnt[u] == 1) {
    	cnt[u] = 0;
    	cek[u][v] = cek[v][u] = 1;
    	cnt[v]--;
    	int a = v;
    	while(cnt[a] == 1) {
    		upd(a);
    		cek[a][ls[a]] = cek[ls[a]][a] = 1;
    		cnt[ls[a]]--;
    		cnt[a]--;
    		a = ls[a];
		}
	} else {
		cek[u][v] = cek[v][u] = 0;
		cnt[u]--;
		cnt[v]--;
		int a = v;
    	while(cnt[a] == 1) {
    		upd(a);
    		cek[a][ls[a]] = cek[ls[a]][a] = 1;
    		cnt[ls[a]]--;
    		cnt[a]--;
    		a = ls[a];
		}
		a = u;
    	while(cnt[a] == 1) {
    		upd(a);
    		cek[a][ls[a]] = cek[ls[a]][a] = 1;
    		cnt[ls[a]]--;
    		cnt[a]--;
    		a = ls[a];
		}
	}
	
	return cek[u][v];
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |