| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|
| 1307311 | | Leyna | 게임 (IOI14_game) | C++20 | | 1095 ms | 6604 KiB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> cnt;
int num;
set<pair<int, int>> questions;
vector<pair<int, int>> edges;
vector<int> rep, sizes;
int find(int u){
if (u == rep[u]) return u;
rep[u] = find(rep[u]);
return rep[u];
}
void uni(int a, int b){
a = find(a);
b = find(b);
if (a == b) return;
if (sizes[a] < sizes[b]) swap(a, b);
rep[b] = a;
sizes[a] += sizes[b];
}
void initialize(int n) {
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
questions.insert({i, j});
}
}
cnt = vector<int>(n);
num = n;
}
bool connected(){
for (int i=1; i<rep.size(); i++){
if (find(i) != find(i-1)) return false;
}
return true;
}
int hasEdge(int u, int v) {
rep = sizes = vector<int>(num, 1);
iota(rep.begin(), rep.end(), 0);
if (v < u) swap(u, v);
questions.erase({u, v});
for (auto[x, y] : questions){
uni(x, y);
}
for (auto[x, y] : edges){
uni(x, y);
}
if (connected()){
return 0;
}
edges.push_back({u, v});
return 1;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |