답안 #730421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730421 2023-04-25T20:55:11 Z grossly_overconfident 게임 (APIO22_game) C++17
컴파일 오류
0 ms 0 KB
#include "game.h"
vector<int> la, sd;
int n, k;
int par(vector<int>& p, int i){
	if (i == p[i]){
		return i;
	}
	return(p, p[i]);
}

void init(int N, int K) {
	n = N;
	k = K;
	la.resize(n);
	sd.resize(n);
	iota(la.begin, la.end(), 0);
	iota(sd.begin(), sd.end(), 0);
}

int add_teleporter(int u, int v) {
	sd[u] = min(par(sd, v), par(sd, u));
	la[v] = min(par(la, v), par(la, u));
	if (sd[u] < la[u] && sd[u] < k && la[u] < k){
		return 1;
	}
	if (sd[v] < la[v] && sd[v] < k && la[v] < k){
		return 1;
	}
	return 0;
}

Compilation message

game.cpp:2:1: error: 'vector' does not name a type
    2 | vector<int> la, sd;
      | ^~~~~~
game.cpp:4:9: error: 'vector' was not declared in this scope
    4 | int par(vector<int>& p, int i){
      |         ^~~~~~
game.cpp:4:16: error: expected primary-expression before 'int'
    4 | int par(vector<int>& p, int i){
      |                ^~~
game.cpp:4:25: error: expected primary-expression before 'int'
    4 | int par(vector<int>& p, int i){
      |                         ^~~
game.cpp:4:30: error: expression list treated as compound expression in initializer [-fpermissive]
    4 | int par(vector<int>& p, int i){
      |                              ^
game.cpp: In function 'void init(int, int)':
game.cpp:14:2: error: 'la' was not declared in this scope
   14 |  la.resize(n);
      |  ^~
game.cpp:15:2: error: 'sd' was not declared in this scope; did you mean 'std'?
   15 |  sd.resize(n);
      |  ^~
      |  std
game.cpp:16:2: error: 'iota' was not declared in this scope
   16 |  iota(la.begin, la.end(), 0);
      |  ^~~~
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:21:2: error: 'sd' was not declared in this scope; did you mean 'std'?
   21 |  sd[u] = min(par(sd, v), par(sd, u));
      |  ^~
      |  std
game.cpp:21:23: error: 'par' cannot be used as a function
   21 |  sd[u] = min(par(sd, v), par(sd, u));
      |                       ^
game.cpp:21:35: error: 'par' cannot be used as a function
   21 |  sd[u] = min(par(sd, v), par(sd, u));
      |                                   ^
game.cpp:21:10: error: 'min' was not declared in this scope
   21 |  sd[u] = min(par(sd, v), par(sd, u));
      |          ^~~
game.cpp:22:2: error: 'la' was not declared in this scope
   22 |  la[v] = min(par(la, v), par(la, u));
      |  ^~
game.cpp:22:23: error: 'par' cannot be used as a function
   22 |  la[v] = min(par(la, v), par(la, u));
      |                       ^
game.cpp:22:35: error: 'par' cannot be used as a function
   22 |  la[v] = min(par(la, v), par(la, u));
      |                                   ^