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 <iostream>
#include <bits/stdc++.h>
using namespace std;
#include "coprobber.h"
// modify the following functions
// you can define global variables and functions
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<array<int, 2>> b;
vector<int> g[n];
for(int i=0; i<n; i++){
for(int l=0; l<n; l++){
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;
q.push_back({i, i, 1});
q.push_back({i, i, 1});
}
while(pos<q.size()){
auto [x, y, z]=q[pos];
if(vis[x][y][z]){ pos++; continue;}
vis[x][y][z]=1;
if(z==0){
if(val[x][y][z]==1)
for(auto i: g[y]){
c[x][i]++;
if(c[x][i]==g[i].size()){
q.push_back({x, i, 1});
}
}
}
else {
for(auto i: g[x]){
b[i][y]=x;
q.push_back({i, y, 0});
}
b[x][y]=x;
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:38: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]
38 | while(pos<q.size()){
| ~~~^~~~~~~~~
coprobber.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | 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... |