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>
#include "coprobber.h"
using namespace std;
vector<vector<int>> AR;
int pos = 0;
int start(int N, bool A[500][500])
{
AR.assign(N, {});
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (A[i][j])
{
AR[i].push_back(j);
AR[j].push_back(i);
}
}
}
return 0;
}
bool dfs(int x, int p, int R)
{
if (x == R)
return 1;
for (int i = 0; i < AR[x].size(); i++)
{
if (AR[x][i] == p)
continue;
if (dfs(AR[x][i], x, R))
return 1;
}
return 0;
}
int nextMove(int R)
{
for (int i = 0; i < AR[pos].size(); i++)
{
if (dfs(AR[pos][i], pos, R))
{
pos = AR[pos][i];
return pos;
}
}
return 0;
}
/*int main()
{
int N = 5;
bool A[5][5] = {{0, 1, 0, 0, 0}, {1, 0, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 0, 1, 0, 1}, {0, 0, 0, 1, 0}};
start(N, A);
nextMove(4);
}*/
Compilation message (stderr)
coprobber.cpp: In function 'bool dfs(int, int, int)':
coprobber.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int i = 0; i < AR[x].size(); i++)
| ~~^~~~~~~~~~~~~~
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i = 0; i < AR[pos].size(); i++)
| ~~^~~~~~~~~~~~~~~~
# | 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... |