# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
950701 |
2024-03-20T15:30:33 Z |
kilkuwu |
Game (IOI14_game) |
C++17 |
|
3 ms |
4700 KB |
#ifdef LOCAL
#ifndef _GAME_H
#define _GAME_H
void initialize(int n);
int hasEdge(int u, int v);
#include <cstdio>
#include <cassert>
#include "game.h"
int read_int() {
int x;
assert(scanf("%d", &x) == 1);
return x;
}
int main() {
int n, u, v;
n = read_int();
initialize(n);
for (int i = 0; i < n * (n - 1) / 2; i++) {
u = read_int();
v = read_int();
printf("%d\n", hasEdge(u, v));
}
return 0;
}
#endif
#else
#include "game.h"
#endif
#include <bits/stdc++.h>
const int mxN = 1500;
int s[mxN][mxN];
int n;
std::vector<int> r[mxN];
int f[mxN];
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; i++) {
r[i].push_back(i);
f[i] = i;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j) s[i][j] = 1;
}
}
}
int hasEdge(int u, int v) {
// let's delete this
s[f[u]][f[v]]--;
if (s[f[u]][f[v]] >= 1) {
return 0;
}
// we move em
// move from one to another
int a = f[u], b = f[v];
for (int i : r[b]) {
r[a].push_back(i);
f[i] = a;
}
for (int i = 0; i < n; i++) {
s[a][i] += s[b][i];
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4700 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4700 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
3 ms |
4620 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |