답안 #739845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739845 2023-05-11T11:44:11 Z dubabuba 게임 (APIO22_game) C++17
컴파일 오류
0 ms 0 KB
#include "game.h"

const int mxn = 3e5 + 10;
const int mxm = 5e5 + 10;
vector<int> adj[mxn];
vector<int> rev[mxn];
int n, k;

int cnt_e[mxn], cnt_b[mxn];

vector<int> top;
void tsort() {
  int t[mxn];
  top.cleat();

  queue<int> q;
  for(int i = 0; i < n; i++) {
    t[i] = cnt_e[i];
    if(t[i] == 0)
      q.push(i);
  }

  while(q.size()) {
    int u = q.top();
    top.push_back(u);
    q.pop();

    for(int v : adj[u]) {
      t[v]--;
      if(t[v] == 0)
        q.push(v);
    }
  }
}

void init(int N, int K) {
  n = N;
  k = K;
}

bool in_top[mxn];
int add_teleporter(int u, int v) {
  adj[u].push_back(v);
  rev[v].push_back(u);
  cnt_b[u]++;
  cnt_e[v]++;

  tsort();
  if(top.size() == n)
    return 0;

  memset(in_top, 0, sizeof in_top);
  for(int u : top)
    in_top[u] = 1;

  for(int i = 0; i < k; i++)
    if(!in_top[i])
      return 1;
  return 0;
}

Compilation message

game.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int> adj[mxn];
      | ^~~~~~
game.cpp:6:1: error: 'vector' does not name a type
    6 | vector<int> rev[mxn];
      | ^~~~~~
game.cpp:11:1: error: 'vector' does not name a type
   11 | vector<int> top;
      | ^~~~~~
game.cpp: In function 'void tsort()':
game.cpp:14:3: error: 'top' was not declared in this scope
   14 |   top.cleat();
      |   ^~~
game.cpp:16:3: error: 'queue' was not declared in this scope
   16 |   queue<int> q;
      |   ^~~~~
game.cpp:16:9: error: expected primary-expression before 'int'
   16 |   queue<int> q;
      |         ^~~
game.cpp:20:7: error: 'q' was not declared in this scope
   20 |       q.push(i);
      |       ^
game.cpp:23:9: error: 'q' was not declared in this scope
   23 |   while(q.size()) {
      |         ^
game.cpp:28:17: error: 'adj' was not declared in this scope
   28 |     for(int v : adj[u]) {
      |                 ^~~
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:43:3: error: 'adj' was not declared in this scope
   43 |   adj[u].push_back(v);
      |   ^~~
game.cpp:44:3: error: 'rev' was not declared in this scope
   44 |   rev[v].push_back(u);
      |   ^~~
game.cpp:49:6: error: 'top' was not declared in this scope
   49 |   if(top.size() == n)
      |      ^~~
game.cpp:52:3: error: 'memset' was not declared in this scope
   52 |   memset(in_top, 0, sizeof in_top);
      |   ^~~~~~
game.cpp:2:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    1 | #include "game.h"
  +++ |+#include <cstring>
    2 | 
game.cpp:53:15: error: 'top' was not declared in this scope
   53 |   for(int u : top)
      |               ^~~