제출 #484318

#제출 시각아이디문제언어결과실행 시간메모리
484318MohamedAliSaidane경찰관과 강도 (BOI14_coprobber)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "coprobber.h" using namespace std; typedef pair<int,int> pii; typedef vector<int> vi; typedef long long ll; typedef pair<ll,ll> pll; typedef tuple<int,int,int> ti; typedef unsigned long long ull; typedef long double ld; typedef vector<ll> vll; typedef pair<ld,ld> pld; #define pb push_back #define popb pop_back() #define pf push_front #define popf pop_front #define ff first #define ss second #define MOD (ll)(1000000007) #define INF (ll) (1e18) #define all(v) (v).begin(),(v).end() const int nx[8] = {0, 0, 1, -1,1,1,-1,-1}, ny[8] = {1, -1, 0, 0,1,-1,1,-1}; //East, West, South, North+ ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;} ////////////******SOLUTION******\\\\\\\\\\\ int n; vi adj[MAX_N]; int state[MAX_N]; int pos; int dp[MAX_N][MAX_N][2]; int f(int i, int j, int turn) { if(dp[i][j][turn] != -1) return dp[i][j][turn]; if(turn == 0) { if(i == j) return dp[i][j][turn] = 0; for(auto e: adj[i]) { if(e == j) continue; if(f(e,j,1-turn) == 0) return dp[i][j][turn] = e; } return dp[i][j][turn] = 0; } else { if(i == j) return dp[i][j][turn] = j; for(auto e: adj[j]) { if(e == i) return dp[i][j][turn] = 0; if(f(i,e,1-turn) == 0) return dp[i][j][turn] = e; } if(f(i,j,1-turn) == 0) return dp[i][j][turn] = 1; return dp[i][j][turn] = 0; } } int nextMove(int r) { return dp[r][pos][1]; } int start(int N, int A[MAX_N][MAX_N]) { n = N; memset(dp,-1,sizeof(dp)); for(int i = 0; i <n-1; i++) { for(int j = i + 1; j <n; j ++) { if(adj[i][j]) { adj[i].pb(j); adj[j].pb(i); } } } memset(state,0,sizeof(state)); for(int j = 0; j <n; j ++) { bool flag = true; for(int i =0; i <n; i ++) { if(dp[i][j][0] != -1) continue; flag = flag & f(i,j,0); } state[j] = flag; } int u = -1; for(int j = 0; j <n; j ++) { u = state[j]? j: u; } return u; } /* 6 3 2 2 5 1 5 1 3 6 3 6 4 3 2 3 4 2 1 6 3 1 6 4 */ /* 6 3 3 1 3 2 3 3 4 6 4 4 5 2 1 3 2 6 3 2 3 2 */

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

coprobber.cpp:25:1: warning: multi-line comment [-Wcomment]
   25 | ////////////******SOLUTION******\\\\\\\\\\\
      | ^
coprobber.cpp:28:8: error: 'MAX_N' was not declared in this scope
   28 | vi adj[MAX_N];
      |        ^~~~~
coprobber.cpp:29:11: error: 'MAX_N' was not declared in this scope
   29 | int state[MAX_N];
      |           ^~~~~
coprobber.cpp:31:8: error: 'MAX_N' was not declared in this scope
   31 | int dp[MAX_N][MAX_N][2];
      |        ^~~~~
coprobber.cpp:31:15: error: 'MAX_N' was not declared in this scope
   31 | int dp[MAX_N][MAX_N][2];
      |               ^~~~~
coprobber.cpp: In function 'int f(int, int, int)':
coprobber.cpp:34:8: error: 'dp' was not declared in this scope
   34 |     if(dp[i][j][turn] != -1)
      |        ^~
coprobber.cpp:39:20: error: 'dp' was not declared in this scope
   39 |             return dp[i][j][turn] = 0;
      |                    ^~
coprobber.cpp:40:21: error: 'adj' was not declared in this scope
   40 |         for(auto e: adj[i])
      |                     ^~~
coprobber.cpp:45:24: error: 'dp' was not declared in this scope
   45 |                 return dp[i][j][turn] = e;
      |                        ^~
coprobber.cpp:47:16: error: 'dp' was not declared in this scope
   47 |         return dp[i][j][turn] = 0;
      |                ^~
coprobber.cpp:52:20: error: 'dp' was not declared in this scope
   52 |             return dp[i][j][turn] = j;
      |                    ^~
coprobber.cpp:53:21: error: 'adj' was not declared in this scope
   53 |         for(auto e: adj[j])
      |                     ^~~
coprobber.cpp:56:24: error: 'dp' was not declared in this scope
   56 |                 return dp[i][j][turn] = 0;
      |                        ^~
coprobber.cpp:58:24: error: 'dp' was not declared in this scope
   58 |                 return dp[i][j][turn] = e;
      |                        ^~
coprobber.cpp:61:20: error: 'dp' was not declared in this scope
   61 |             return dp[i][j][turn] = 1;
      |                    ^~
coprobber.cpp:62:16: error: 'dp' was not declared in this scope
   62 |         return dp[i][j][turn] = 0;
      |                ^~
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:67:12: error: 'dp' was not declared in this scope
   67 |     return dp[r][pos][1];
      |            ^~
coprobber.cpp: At global scope:
coprobber.cpp:69:24: error: 'MAX_N' was not declared in this scope
   69 | int start(int N, int A[MAX_N][MAX_N])
      |                        ^~~~~
coprobber.cpp:69:31: error: 'MAX_N' was not declared in this scope
   69 | int start(int N, int A[MAX_N][MAX_N])
      |                               ^~~~~
coprobber.cpp: In function 'int start(...)':
coprobber.cpp:71:9: error: 'N' was not declared in this scope
   71 |     n = N;
      |         ^
coprobber.cpp:72:12: error: 'dp' was not declared in this scope
   72 |     memset(dp,-1,sizeof(dp));
      |            ^~
coprobber.cpp:77:16: error: 'adj' was not declared in this scope
   77 |             if(adj[i][j])
      |                ^~~
coprobber.cpp:84:12: error: 'state' was not declared in this scope
   84 |     memset(state,0,sizeof(state));
      |            ^~~~~