Submission #163481

#TimeUsernameProblemLanguageResultExecution timeMemory
163481GioChkhaidzeGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include "game.h"
using namespace std;
int a[35005],p[35005];

void P(int x) {
	if (p[x]==x) return x;
  	return p[x]=P(p[x]);
}

void Uni(int a,int b) {
    a=P(a);
    b=P(b);
	p[b]=a;
}

void initialize(int n) {
  for (int i=1; i<=n; i++) 
  	p[i]=i,a[i]=n-1;
}
 
int hasEdge(int u,int v) {
	u++,v++;
    if (P(u)==P(v)) return 1;
  	if (a[u]==1 || a[v]==1) {
      Uni(u,v);
      return 1;
    }
  
    a[u]--,a[v]--;
  	return 0;
}

Compilation message (stderr)

game.cpp: In function 'void P(int)':
game.cpp:6:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
  if (p[x]==x) return x;
                      ^
game.cpp:7:22: error: void value not ignored as it ought to be
    return p[x]=P(p[x]);
                      ^
game.cpp:7:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
game.cpp: In function 'void Uni(int, int)':
game.cpp:11:10: error: void value not ignored as it ought to be
     a=P(a);
          ^
game.cpp:12:10: error: void value not ignored as it ought to be
     b=P(b);
          ^
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:23:13: error: invalid operands of types 'void' and 'void' to binary 'operator=='
     if (P(u)==P(v)) return 1;
         ~~~~^~~~~~