# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320904 | shrek12357 | Cop and Robber (BOI14_coprobber) | C++14 | 169 ms | 262148 KiB |
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 <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
#include "coprobber.h"
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);
const int MAXN = 505;
bool found[MAXN][MAXN];
vector<int> adjList[MAXN];
int cur = 0, par = 0;
void dfs(int src, int par) {
found[src][src] = true;
for (auto i : adjList[src]) {
if (i == par) {
continue;
}
dfs(i, src);
for (int j = 0; j < MAXN; j++) {
found[src][j] |= found[i][j];
}
}
}
int start(int N, bool A[MAX_N][MAX_N]) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (A[i][j]) {
adjList[i].push_back(j);
}
}
}
dfs(0, 0);
return cur;
}
int nextMove(int R) {
if (cur == R) {
return R;
}
for (auto i : adjList[cur]) {
if (i == par) {
continue;
}
if (found[i][R]) {
par = cur;
cur = i;
return cur;
}
}
}
Compilation message (stderr)
# | 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... |