Submission #931303

# Submission time Handle Problem Language Result Execution time Memory
931303 2024-02-21T14:57:35 Z _fractal Game (IOI14_game) C++14
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1501;
 
int p[N], sz[N];
int cnt[N][N], n;
 
int get(int v){
    return (p[v] == v ? v : (p[v] = get(p[v])));
}
 
void unite(int a, int b){
    a = get(a);
    b = get(b);
    if(a == b)
        return;
    if(sz[a] > sz[b])
        swap(a, b);
    p[a] = b;
    sz[b] += sz[a];
    for(int i = 1; i <= n; i++){
      	if (p[i] == i && i != b && i != a) {
	        cnt[b][i] += cnt[a][i];
	        cnt[i][b] += cnt[a][i];
        }
    }
}
 
void initialize(int sa){
    n = sa;
    for(int i = 1; i <= n; i++){
        p[i] = i;
        sz[i] = 1;
    }
}
 
int hasEdge(int u, int v){
    u = get(u);
    v = get(v);
    if(sz[u] * sz[v] - 1 == cnt[v][u]){
        unite(u, v);
        return 1;
    }else{
        cnt[v][u]++;
        cnt[u][v]++;
        return 0;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -