Submission #484428

#TimeUsernameProblemLanguageResultExecution timeMemory
484428MohamedAliSaidaneCop and Robber (BOI14_coprobber)C++14
0 / 100
1 ms2248 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 pos = -1; int nextMove(int r) { return pos = dp[r][pos][1]; } int 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)); 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******\\\\\\\\\\\
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...