This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "coprobber.h"
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=500;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
struct st{
int a,b,c;
};
bool dp[N][N][2];
int nxt[N][N],il[N][N],last;
vi graf[N];
int start(int n, bool t[N][N]){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
if(t[i][j]) graf[i].push_back(j);
}
deque<st>deq;
for(int i=0;i<n;i++){
deq.push_back({i,i,0}),deq.push_back({i,i,1});
dp[i][i][0]=1,dp[i][i][1]=1;
}
while(deq.size()){
st v=deq.front();
deq.pop_front();
if(v.c){
for(auto u:graf[v.b]){
il[u][v.a]++;
if(il[u][v.a]==graf[u].size()) deq.push_back({u,v.a,0}),dp[u][v.a][0]=1;
}
}else{
for(auto u:graf[v.b])
if(!dp[u][v.a][1]) deq.push_back({u,v.a,1}),nxt[u][v.a]=v.b,dp[u][v.a][1]=1;
if(!dp[v.b][v.a][1]) deq.push_back({v.b,v.a,1}),nxt[v.b][v.a]=v.b,dp[v.b][v.a][1]=1;
}
}
for(int i=0;i<n;i++){
bool ok=1;
for(int k=0;k<n;k++) ok&=dp[i][k][1];
if(ok){
last=i;
return i;
}
}
return -1;
}
int nextMove(int R){
int res=nxt[last][R];
last=res;
return res;
}
Compilation message (stderr)
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if(il[u][v.a]==graf[u].size()) deq.push_back({u,v.a,0}),dp[u][v.a][0]=1;
| ~~~~~~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |