제출 #381619

#제출 시각아이디문제언어결과실행 시간메모리
381619ritul_kr_singh게임 (IOI14_game)C++17
컴파일 에러
0 ms0 KiB
#include "game.h" #include "bits/stdc++.h" vector<int> e; int find(int u){ return e[u] < 0 ? u : e[u] = find(e[u]); } int sz(int u){ return -e[find(u)]; } void union(int u, int v){ u = find(u), v = find(v); if(u==v) return; if(e[u] > e[v]) swap(u, v); e[u] += e[v], e[v] = u; } void initialize(int n){ e.assign(n+1, -1); } int hasEdge(int u, int v){ if(find(u)==find(v) or sz(u)+sz(v)<n){ union(u, v); return 1; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

game.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> e;
      | ^~~~~~
game.cpp: In function 'int find(int)':
game.cpp:6:9: error: 'e' was not declared in this scope
    6 |  return e[u] < 0 ? u : e[u] = find(e[u]);
      |         ^
game.cpp: In function 'int sz(int)':
game.cpp:9:10: error: 'e' was not declared in this scope
    9 |  return -e[find(u)];
      |          ^
game.cpp: At global scope:
game.cpp:11:11: error: expected identifier before '(' token
   11 | void union(int u, int v){
      |           ^
game.cpp:11:12: error: expected unqualified-id before 'int'
   11 | void union(int u, int v){
      |            ^~~
game.cpp:11:12: error: expected ')' before 'int'
   11 | void union(int u, int v){
      |           ~^~~
      |            )
game.cpp: In function 'void initialize(int)':
game.cpp:20:2: error: 'e' was not declared in this scope
   20 |  e.assign(n+1, -1);
      |  ^
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:24:37: error: 'n' was not declared in this scope
   24 |  if(find(u)==find(v) or sz(u)+sz(v)<n){
      |                                     ^
game.cpp:25:3: error: expected primary-expression before 'union'
   25 |   union(u, v);
      |   ^~~~~