# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
921175 |
2024-02-03T11:47:09 Z |
pera |
게임 (IOI14_game) |
C++17 |
|
6 ms |
9560 KB |
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 1500 + 1;
int X;
vector<int> parent(N);
vector<vector<int>> bad(N + 1 , vector<int>(N + 1));
void initialize(int n){
++n;
X = n;
for(int i = 1;i <= n;i ++){
parent[i] = i;
for(int j = 1;j <= n;j ++){
bad[i][j] = (i != j);
}
}
}
int find(int u){
return (u == parent[u] ? u : parent[u] = find(parent[u]));
}
void unite(int u , int v){
u = find(u);
v = find(v);
if(u != v){
for(int x = 1;x <= X;x ++){
if(x != u && x != v){
bad[x][u] += bad[x][v];
bad[u][x] = bad[x][u];
}
}
parent[v] = u;
}
}
int hasEdge(int u , int v){
++u , ++v;
int U = find(u) , V = find(v);
if(U == V){
return 0;
}
if(bad[U][V] == 1){
unite(u , v);
return 1;
}else{
bad[U][V]--;
return 0;
}
}
/*int main(){
int n;
cin >> n;
initialize(n);
for(int i = 1;i <= n * (n + 1) / 2;i ++){
int u , v;
cin >> u >> v;
cout << hasEdge(u , v) << endl;
}
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9308 KB |
Output is correct |
2 |
Correct |
6 ms |
9308 KB |
Output is correct |
3 |
Correct |
5 ms |
9308 KB |
Output is correct |
4 |
Correct |
5 ms |
9308 KB |
Output is correct |
5 |
Correct |
4 ms |
9308 KB |
Output is correct |
6 |
Correct |
5 ms |
9304 KB |
Output is correct |
7 |
Incorrect |
5 ms |
9308 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9308 KB |
Output is correct |
2 |
Correct |
5 ms |
9324 KB |
Output is correct |
3 |
Correct |
5 ms |
9304 KB |
Output is correct |
4 |
Correct |
5 ms |
9308 KB |
Output is correct |
5 |
Correct |
5 ms |
9200 KB |
Output is correct |
6 |
Correct |
5 ms |
9308 KB |
Output is correct |
7 |
Incorrect |
5 ms |
9308 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9308 KB |
Output is correct |
2 |
Correct |
5 ms |
9308 KB |
Output is correct |
3 |
Correct |
5 ms |
9308 KB |
Output is correct |
4 |
Correct |
5 ms |
9560 KB |
Output is correct |
5 |
Correct |
5 ms |
9308 KB |
Output is correct |
6 |
Correct |
5 ms |
9304 KB |
Output is correct |
7 |
Incorrect |
5 ms |
9560 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |