Submission #136476

#TimeUsernameProblemLanguageResultExecution timeMemory
136476cfalasGame (IOI14_game)C++14
15 / 100
3 ms408 KiB
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
#define INF 10000

int n;
int con[INF];
int cnt[INF];

void initialize(int x){
	n = x;
}

int hasEdge(int u, int v){
	cnt[u]++;
	cnt[v]++;
	//cout<<u<<" "<<v<<endl;
	//cout<<cnt[u]<<" "<<cnt[v]<<endl;
	bool ok = false;
	for(int i=0;i<n;i++){
		if(cnt[i]!=n-2){
			ok = true;

		}
	}
	if(ok){
	if(cnt[u]==n-1 && cnt[v]<=n-1 && con[u]<=2 || cnt[v]==n-1 && cnt[u]<=n-1 && con[v]<=2){
		con[u]++;
		con[v]++;
		return 1;
	}}
	else return 1;
	return 0;
}

Compilation message (stderr)

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:27:32: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  if(cnt[u]==n-1 && cnt[v]<=n-1 && con[u]<=2 || cnt[v]==n-1 && cnt[u]<=n-1 && con[v]<=2){
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...