제출 #983747

#제출 시각아이디문제언어결과실행 시간메모리
983747sleepntsheep게임 (IOI14_game)C11
0 / 100
1 ms2396 KiB
#include "game.h" #define NN 1500 int n, ds[NN], cross[NN][NN]; int find(int i) { if (ds[i] < 0) return i; int p = find(ds[i]); for (int j = 0; j < n; ++j) cross[p][j] += cross[i][j], cross[j][p] += cross[i][j]; return ds[i] = p; } int unite(int i, int j) { i = find(i), j = find(j); if (i == j) return 0; ds[i] += ds[j]; ds[j] = i; return 1; } void initialize(int n0) { n = n0; for (int i = 0; i < n; ++i) ds[i] = -1; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cross[i][j] = cross[j][i] = 1; } int hasEdge(int u, int v) { if (find(u) == find(v)) return 1; u = find(u), v = find(v); --cross[u][v]; --cross[v][u]; if (0 == cross[u][v]) { unite(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...