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 <bits/stdc++.h>
using namespace std;
# include "coprobber.h"
int pos;
int val[505][505][2];
int vis[505][505][2];
int b[505][505], c[505][505];
int start(int n, bool a[MAX_N][MAX_N]) {
vector<int> g[n+1];
for(int i=0; i<n; i++){
for(int l=0; l<n; l++){
b[i][l]=-1;
if(a[i][l]){
g[i].push_back(l);
}
}
}
vector<array<int, 3>> q;
for(int i=0; i<n; i++){
val[i][i][0]=1;
val[i][i][1]=0;
b[i][i]=i;
q.push_back({i, i, 1});
q.push_back({i, i, 0});
}
while(pos<q.size()){
auto [x, y, z]=q[pos];
if(vis[x][y][z]){
pos++;
}
else{
// cout<<val[x][y][z]<<"\n";
vis[x][y][z]=1;
if(z==0){
val[x][y][z]=1;
for(auto i: g[y]){
if(vis[x][i][1]) continue;
c[x][i]++;
if(c[x][i]==g[i].size()){
val[x][i][1]=0;
q.push_back({x, i, 1});
}
}
}
else {
val[x][y][z] = 0;
for(auto i: g[x]){
if(vis[i][y][0]) continue;
if(b[i][y]==-1)
b[i][y]=x;
q.push_back({i, y, 0});
}
if(b[x][y]==-1)
b[x][y]=x;
if(!vis[x][y][0])
q.push_back({x, y, 0});
}
pos++;
}
}
for(int i=0; i<n; i++){
int flag=1;
for(int j=0; j<n; j++){
if(val[i][j][0]==0){
flag=0;
}
}
if(flag){
return pos=i;
}
}
return -1;
}
int nextMove(int R) {
return pos=b[pos][R];
}
Compilation message (stderr)
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:33:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | while(pos<q.size()){
| ~~~^~~~~~~~~
coprobber.cpp:46:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if(c[x][i]==g[i].size()){
| ~~~~~~~^~~~~~~~~~~~~
# | 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... |