#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 MAX_NN = 500;
int n;
vi adj[MAX_NN];
int state[MAX_NN];
int pos;
int dp[MAX_NN][MAX_NN][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, bool A[MAX_NN][MAX_NN])
{
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 ++)
{
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
*/
Compilation message
coprobber.cpp:25:1: warning: multi-line comment [-Wcomment]
25 | ////////////******SOLUTION******\\\\\\\\\\\
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4424 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4424 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4404 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4424 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |