제출 #31721

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
317212017-09-01 11:55:23top34051게임 (IOI14_game)C++14
100 / 100
889 ms19664 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define maxn 1505
int n;
int head[maxn];
int way[maxn][maxn];
int temp[maxn];
int findhead(int x) {
if(head[x]==x) return x;
return head[x] = findhead(head[x]);
}
void initialize(int N) {
int i,j;
n = N;
for(i=0;i<n;i++) head[i] = i;
for(i=0;i<n;i++) for(j=0;j<n;j++) way[i][j] = 1;
}
int hasEdge(int u, int v) {
u = findhead(u); v = findhead(v);
if(u==v) return 0;
if(way[u][v]==1) {
for(int i=0;i<n;i++) temp[i] = way[u][i] + way[v][i];
head[findhead(v)] = findhead(u);
for(int i=0;i<n;i++) way[findhead(u)][i] = way[i][findhead(u)] = temp[i];
return 1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...