Submission #250161

#TimeUsernameProblemLanguageResultExecution timeMemory
250161Kevin_Zhang_TW경찰관과 강도 (BOI14_coprobber)C++17
Compilation error
0 ms0 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; #define pb emplace_back #define MAX_N 500 const int inf = 1e9; // modify the following functions // you can define global variables and functions int now, n; vector<int> edge[MAX_N]; bool con[MAX_N][MAX_N], win[MAX_N][MAX_N]; int mv[MAX_N][MAX_N]; bool check(int a, int b) { if (a == b) return true; //cerr <<" A B " << a << ' ' << b << '\n'; for (int u : edge[b]) { if (!con[a][u]) return false; //cerr << "CON " << a << ' ' << u << '\n'; } return true; } int start(int N, bool A[MAX_N][MAX_N]) { n = N; for (int i = 0;i < n;++i) { for (int j = 0;j < n;++j) if (A[i][j]) con[i][j] = true, edge[i].pb(j);//, con[i][j] = A[i][j], con[i][i] = true; } con[i][i] = true; } for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) { win[i][j] = check(i, j); //cerr << "win " << i << ' ' << j << " : " <<(win[i][j] ?"WIN ": "LOSE") << '\n'; } //exit(0); bool ch = true; while (ch) { ch = false; for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) if (!win[i][j]) { bool esc = false; for (int u : edge[j]) { bool die = false; for (int k : edge[i]) { if (win[k][u]) { die = true; break; } } die |= win[i][u]; if (!die) esc = true; if (esc) break; } if (!esc) win[i][j] = true, ch = true; } } // for (int i = 0;i < n;++i) // for (int j = 0;j < n;++j) // printf("win[%d][%d] : %d\n", i, j, (int)win[i][j]); // exit(0); for (int i = 0;i < n;++i) { bool allwin = true; for (int j = 0;j < n;++j) if (!win[i][j]) { allwin = false; break; } if (allwin) { assert(i == 0); return now = i; } } return -1; } int nextMove(int R) { if (now == R) return now; for (int u : edge[now]) if (win[u][R]) return now = u; return now; }

Compilation message (stderr)

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:29:7: error: 'i' was not declared in this scope
   con[i][i] = true;
       ^
coprobber.cpp:30:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
coprobber.cpp: At global scope:
coprobber.cpp:31:2: error: expected unqualified-id before 'for'
  for (int i = 0;i < n;++i)
  ^~~
coprobber.cpp:31:17: error: 'i' does not name a type
  for (int i = 0;i < n;++i)
                 ^
coprobber.cpp:31:23: error: expected unqualified-id before '++' token
  for (int i = 0;i < n;++i)
                       ^~
coprobber.cpp:32:18: error: 'j' does not name a type
   for (int j = 0;j < n;++j) {
                  ^
coprobber.cpp:32:24: error: expected unqualified-id before '++' token
   for (int j = 0;j < n;++j) {
                        ^~
coprobber.cpp:39:2: error: expected unqualified-id before 'while'
  while (ch) {
  ^~~~~
coprobber.cpp:63:2: error: expected unqualified-id before 'for'
  for (int i = 0;i < n;++i) {
  ^~~
coprobber.cpp:63:17: error: 'i' does not name a type
  for (int i = 0;i < n;++i) {
                 ^
coprobber.cpp:63:23: error: expected unqualified-id before '++' token
  for (int i = 0;i < n;++i) {
                       ^~
coprobber.cpp:75:2: error: expected unqualified-id before 'return'
  return -1;
  ^~~~~~
coprobber.cpp:76:1: error: expected declaration before '}' token
 }
 ^