Submission #889135

# Submission time Handle Problem Language Result Execution time Memory
889135 2023-12-19T02:22:45 Z shezitt Game (IOI14_game) C++14
0 / 100
1 ms 500 KB
#include "game.h"
#include <bits/stdc++.h>
 
// Subtask 1 n = 4
 
using namespace std;
 
const int N = 1505;
int cont[N];
int pa[N];
int tam[N];
int neg = 0;
int n, r;

int find(int x){
    if(x == pa[x]) return x;
    return pa[x] = find(pa[x]);
}

void join(int a, int b){
    a = find(a), b = find(b);
    if(tam[a] > tam[b]) swap(a, b);
    pa[a] = b;
    tam[b] += tam[a];
    return;
}

void initialize(int nn) {
    memset(cont, 0, sizeof cont);
    neg = 0;
    n = nn;
    r = n * (n - 1) / 2;
    for(int i=0; i<n; ++i){
        pa[i] = i;
        tam[i] = 1;
    }
    return;
}
 
int hasEdge(int u, int v) {
    if(tam[find(u)] + tam[find(v)] == n){
        // must be negative
        return 0;
    }
    join(u, v);
    return 1;
    // if(cont[u] == n-2 or cont[v] == n-2){
    //     // must be positive
    //     return 1;
    // }
    // if(neg == r - n + 1){
    //     // must be positive
    //     return 1;
    // }
    // cont[u]++;
    // cont[v]++;
    // neg++;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 500 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -