Submission #936016

# Submission time Handle Problem Language Result Execution time Memory
936016 2024-03-01T01:45:14 Z peterandvoi Game (IOI14_game) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef ngu
#include "debug.h"
#else
#define debug(...) 42
#endif

vector<vector<int>> cnt;
vector<int> lab;

int get(int u) {
    return lab[u] < 0 ? u : lab[u] = get(lab[u]);
}

int hasEdge(int u, int v) {
    u = get(u);
    v = get(v);
    if (cnt[u][v] > 1) }
        cnt[u][v]--;
        return 0;
    }
    if (lab[u] > lab[v]) {
        swap(u, v);
    }
    lab[u] += lab[v];
    lab[v] = u;
    for (int i = 0; i < n; ++i) {
        cnt[u][i] += cnt[v][i];
        cnt[i][u] = cnt[u][i];
    }
    return 1;
}

void initialize(int n) {
    cnt.resize(n, vector<int>(n));
    lab.resize(n, -1);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cnt[i][j] = i != j;
        }
    }
}

Compilation message

game.cpp: In function 'int hasEdge(int, int)':
game.cpp:21:24: error: expected primary-expression before '}' token
   21 |     if (cnt[u][v] > 1) }
      |                        ^
game.cpp:21:24: warning: no return statement in function returning non-void [-Wreturn-type]
game.cpp: At global scope:
game.cpp:22:9: error: 'cnt' does not name a type
   22 |         cnt[u][v]--;
      |         ^~~
game.cpp:23:9: error: expected unqualified-id before 'return'
   23 |         return 0;
      |         ^~~~~~
game.cpp:24:5: error: expected declaration before '}' token
   24 |     }
      |     ^
game.cpp:25:5: error: expected unqualified-id before 'if'
   25 |     if (lab[u] > lab[v]) {
      |     ^~
game.cpp:28:5: error: 'lab' does not name a type
   28 |     lab[u] += lab[v];
      |     ^~~
game.cpp:29:5: error: 'lab' does not name a type
   29 |     lab[v] = u;
      |     ^~~
game.cpp:30:5: error: expected unqualified-id before 'for'
   30 |     for (int i = 0; i < n; ++i) {
      |     ^~~
game.cpp:30:21: error: 'i' does not name a type
   30 |     for (int i = 0; i < n; ++i) {
      |                     ^
game.cpp:30:28: error: expected unqualified-id before '++' token
   30 |     for (int i = 0; i < n; ++i) {
      |                            ^~
game.cpp:34:5: error: expected unqualified-id before 'return'
   34 |     return 1;
      |     ^~~~~~
game.cpp:35:1: error: expected declaration before '}' token
   35 | }
      | ^