답안 #349721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349721 2021-01-18T09:23:52 Z Pety 게임 (IOI14_game) C++14
0 / 100
54 ms 26092 KB
#include <bits/stdc++.h>


using namespace std;

int n, sz[2000], p[2000], cnt[2000][2000];

int find (int x) {
  if (p[x] == x)
    return x;
  return p[x] = find(p[x]);
}

void Union (int x, int y) {
  if (x != y) {
    if (sz[x] < sz[y])
      swap(x, y);
    for (int i = 1; i <= n; i++)
      cnt[i][x] += cnt[i][y];
    p[y] = x;
  }
  return;
}

int initialize(int m) {
  n = m;
  for (int i = 1; i <= n; i++)  {
    sz[i] = 1;
    p[i] = i;
    for (int j = 1; j <= n; j++)
      cnt[i][j] = (i != j);
  }
}

int hasEdge (int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return 0;
  if (cnt[x][y] > 1)
    return 0;
  return 1;
}

Compilation message

game.cpp: In function 'int initialize(int)':
game.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
   33 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 26092 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 26092 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 54 ms 26092 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -