Submission #484426

#TimeUsernameProblemLanguageResultExecution timeMemory
484426MohamedAliSaidaneCop and Robber (BOI14_coprobber)C++14
Compilation error
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******\\\\\\\\\\\ const int MAXX = 500; int n; vi adj[MAXX]; int dp[MAXX][MAXX][2]; bool visited[MAXX][MAXX][2]; int f(int i, int j, int turn) { if(dp[i][j][turn] != -1) return dp[i][j][turn]; visited[i][j][turn] = 1; int ans; if(turn == 0) { ans = -2; for(auto e: adj[i]) { if(i == j) break; if(f(e,j,1-turn) == -2) { ans = e; break; } } } else { ans = -2; if(i == j) return dp[i][j][turn] = i; if(!visited[i][j][1-turn]) ans = f(i,j,1-turn); for(auto e: adj[j]) { if(visited[i][e][1-turn]) continue; if(f(i,e,1-turn) == -2) { ans = e; break; } } } visited[i][j][turn] = 0; return dp[i][j][turn] = ans; } int nextMove(int r) { return pos = dp[r][pos][1]; } void start(int N, bool A[MAXX][MAXX]) { n = N; memset(dp,-1,sizeof(dp)); for(int i = 0; i <n-1 ; i ++) { for(int j = i + 1; j<n; j ++) { if(A[i][j]) { adj[i].pb(j); adj[j].pb(i); } } } bool gagn[n]; memset(gagn,false,sizeof(gagn)); int pos = -1; for(int j = 0; j <n; j ++) { bool flag = true; for(int i = 0; i <n; i ++) { flag = flag & f(i,j,1); f(i,j,0); } gagn[j] = flag; if(flag) pos= j; } return pos; } /*int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; while(tt--) solve(); }*/

Compilation message (stderr)

coprobber.cpp:25:1: warning: multi-line comment [-Wcomment]
   25 | ////////////******SOLUTION******\\\\\\\\\\\
      | ^
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:76:12: error: 'pos' was not declared in this scope; did you mean 'pow'?
   76 |     return pos = dp[r][pos][1];
      |            ^~~
      |            pow
coprobber.cpp: At global scope:
coprobber.cpp:78:6: error: ambiguating new declaration of 'void start(int, bool (*)[500])'
   78 | void start(int N, bool A[MAXX][MAXX])
      |      ^~~~~
In file included from coprobber.cpp:2:
coprobber.h:6:5: note: old declaration 'int start(int, bool (*)[500])'
    6 | int start(int N, bool A[MAX_N][MAX_N]);
      |     ^~~~~
coprobber.cpp: In function 'void start(int, bool (*)[500])':
coprobber.cpp:108:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
  108 |     return pos;
      |            ^~~