# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1181270 | Kerim | Game (IOI14_game) | C++17 | 1 ms | 320 KiB |
#include "game.h"
#include <algorithm>
using namespace std;
const int N = 1502;
int ata[N], C;
int tap(int x){
if (ata[x] == x)
return ata[x];
return ata[x] = tap(ata[x]);
}
int merge(int x, int y){
if ((x=tap(x)) == (y=tap(y)))
return 0;
ata[y] = x;
}
bool is_connected(int x, int y){
return (tap(x) == tap(y));
}
void initialize(int n) {
C = n;
for (int i = 0; i < n; i++)
ata[i] = i;
}
int hasEdge(int u, int v) {
if (!is_connected(u, v)){
if (C == 2)
return 0;
else{
merge(u, v);
C -= 1;
return 1;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |