Submission #1062933

#TimeUsernameProblemLanguageResultExecution timeMemory
1062933damjandavkovGame (IOI14_game)C++17
0 / 100
1 ms348 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v;
vector<int> pa, sz;
int N;
int fin(int i)
{
    if (pa[i] == i)
        return i;
    pa[i] = fin(pa[i]);
    return pa[i];
}
int mer(int a, int b)
{
    a = fin(a);
    b = fin(b);
    if (sz[a] > sz[b])
        swap(a, b);
    pa[a] = b;
    sz[b] += sz[a];
    for (int i = 0; i < N; i++)
    {
        if (pa[i] != i || i == a || i == b)
            continue;
        v[i][b] += v[i][a];
        v[b][i] += v[a][i];
    }
}
void initialize(int n)
{
    int i, j;
    N = n;
    pa.resize(n);
    sz.resize(n);
    v.resize(n);
    for (i = 0; i < n; i++)
    {
        pa[i] = i;
        sz[i] = 1;
        v[i].resize(n);
        for (j = 0; j < n; j++)
            v[i][j] = 1;
    }
}
int hasEdge(int a, int b)
{
    a = fin(a);
    b = fin(b);
    if (v[a][b] > 1)
    {
        v[a][b]--;
        return 0;
    }
    mer(a, b);
    return 1;
}

Compilation message (stderr)

game.cpp: In function 'int mer(int, int)':
game.cpp:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
   29 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...