Submission #422131

#TimeUsernameProblemLanguageResultExecution timeMemory
422131daanolavGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include "game.h"

int n;

int ufParent[MAXN];
int ufSize[MAXN];
int ufLinkingPossibilities[MAXN];
vi ufPossibleConnections[MAXN];

int ufFind(int a) {
    if(ufParent[a] == a) {
        return a;
    }
    ufParent[a] = ufFind(ufParent[a]);
    return ufParent[a];
}

void ufUnite(int a, int b) {
    a = ufFind(a);
    b = ufFind(b);
    if(ufSize[a] > ufSize[b]) {
        swap(a,b);
    }


    ufParent[b] = a;
    ufSize[a] += ufSize[b];
    for(int i = 0; i < n; ++i) {
        if(i == a || i == b) {
            //ufLinkingPossibilities[a] -= ufPossibleConnections[a][i];
            ufPossibleConnections[a][i] = 0;
        } else {
            ufPossibleConnections[a][i] += ufPossibleConnections[b][i];
            //ufLinkingPossibilities[a] += ufPossibleConnections[b][i];

            ufPossibleConnections[i][a] += ufPossibleConnections[i][b];
            ufPossibleConnections[i][b] = 0;
        }
    }

}

void initialize(int n) {
    ::n = n;
    for(int i = 0; i < n; ++i) {
        ufParent[i] = i;
        ufSize[i] = 1;
        ufLinkingPossibilities[i] = 0;
        for(int j = 0; j < n; ++j) {
            if(i == j) {
                ufPossibleConnections[i].push_back(0);
                continue;
            }
            ufPossibleConnections[i].push_back(1);
            ufLinkingPossibilities[i] += 1;

        }
    }

}

int hasEdge(int u,int v) {
    if(ufPossibleConnections[ufFind(u)][ufFind(v)] > 1) {
        return 0;
    } else {
        ufUnite(u,v);
        return 1;
    }
}

Compilation message (stderr)

game.cpp:5:14: error: 'MAXN' was not declared in this scope
    5 | int ufParent[MAXN];
      |              ^~~~
game.cpp:6:12: error: 'MAXN' was not declared in this scope
    6 | int ufSize[MAXN];
      |            ^~~~
game.cpp:7:28: error: 'MAXN' was not declared in this scope
    7 | int ufLinkingPossibilities[MAXN];
      |                            ^~~~
game.cpp:8:1: error: 'vi' does not name a type
    8 | vi ufPossibleConnections[MAXN];
      | ^~
game.cpp: In function 'int ufFind(int)':
game.cpp:11:8: error: 'ufParent' was not declared in this scope
   11 |     if(ufParent[a] == a) {
      |        ^~~~~~~~
game.cpp:14:5: error: 'ufParent' was not declared in this scope
   14 |     ufParent[a] = ufFind(ufParent[a]);
      |     ^~~~~~~~
game.cpp: In function 'void ufUnite(int, int)':
game.cpp:21:8: error: 'ufSize' was not declared in this scope
   21 |     if(ufSize[a] > ufSize[b]) {
      |        ^~~~~~
game.cpp:22:9: error: 'swap' was not declared in this scope
   22 |         swap(a,b);
      |         ^~~~
game.cpp:26:5: error: 'ufParent' was not declared in this scope
   26 |     ufParent[b] = a;
      |     ^~~~~~~~
game.cpp:27:5: error: 'ufSize' was not declared in this scope
   27 |     ufSize[a] += ufSize[b];
      |     ^~~~~~
game.cpp:31:13: error: 'ufPossibleConnections' was not declared in this scope
   31 |             ufPossibleConnections[a][i] = 0;
      |             ^~~~~~~~~~~~~~~~~~~~~
game.cpp:33:13: error: 'ufPossibleConnections' was not declared in this scope
   33 |             ufPossibleConnections[a][i] += ufPossibleConnections[b][i];
      |             ^~~~~~~~~~~~~~~~~~~~~
game.cpp: In function 'void initialize(int)':
game.cpp:46:9: error: 'ufParent' was not declared in this scope
   46 |         ufParent[i] = i;
      |         ^~~~~~~~
game.cpp:47:9: error: 'ufSize' was not declared in this scope
   47 |         ufSize[i] = 1;
      |         ^~~~~~
game.cpp:48:9: error: 'ufLinkingPossibilities' was not declared in this scope
   48 |         ufLinkingPossibilities[i] = 0;
      |         ^~~~~~~~~~~~~~~~~~~~~~
game.cpp:51:17: error: 'ufPossibleConnections' was not declared in this scope
   51 |                 ufPossibleConnections[i].push_back(0);
      |                 ^~~~~~~~~~~~~~~~~~~~~
game.cpp:54:13: error: 'ufPossibleConnections' was not declared in this scope
   54 |             ufPossibleConnections[i].push_back(1);
      |             ^~~~~~~~~~~~~~~~~~~~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:63:8: error: 'ufPossibleConnections' was not declared in this scope
   63 |     if(ufPossibleConnections[ufFind(u)][ufFind(v)] > 1) {
      |        ^~~~~~~~~~~~~~~~~~~~~
game.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
   69 | }
      | ^