#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
int n, m, a, b, p, dp[505][505][2], nxt[505][505], in[505][505];
bool u[505][505][2], t;
vector<int> v[505];
queue<pair<pii, pii> > q;
#define top front
int start (int N, bool A[][500]){
fox(l, N){
fox(l2, N){
if (A[l][l2]) {
v[l].pb(l2);
fox(l3, N){
in[l3][l2]++;
}
}
}
}
fox(l, N){
q.push(mp(mp(l, l), mp(0, -1)));
q.push(mp(mp(l, l), mp(1, -1)));
}
while(!q.empty()){
a=q.top().x.x; b=q.top().x.y; t=q.top().y.x; p=q.top().y.y; q.pop();
if (u[a][b][t]) continue;
if (t) nxt[a][b]=p;
u[a][b][t]=1;
//cout << a << ' ' << b << ' ' << t<< endl;
if (!t){
fox(l, v[b].size()){
in[a][v[b][l]]--;
if (in[a][v[b][l]]==0){
q.push(mp(mp(a, v[b][l]), mp(!t, b)));
}
}
} else {
fox(l, v[a].size()){
q.push(mp(mp(v[a][l], b), mp(!t, a)));
}
}
}
fox(l, N){
bool f=1;
fox(l2, N){
if (u[l][l2][1]==0){
f=0;
break;
}
}
if (f){
return l;
}
}
return -1;
}
int nextMove(int R){
m=R;
if (n==m) return n;
n=nxt[n][m];
return n;
}
/*int main(){
int n;
bool a[500][500];
cin >> n;
fox(l, n) fox(l2, n) cin >> a[l][l2];
//fox(l, n) fox(l2, n) cout << dp[l][l2][0];
cout << start(n, a);
}*/
Compilation message
coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
coprobber.cpp:54:17:
fox(l, v[b].size()){
~~~~~~~~~~~~~~
coprobber.cpp:54:13: note: in expansion of macro 'fox'
fox(l, v[b].size()){
^~~
coprobber.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
coprobber.cpp:61:17:
fox(l, v[a].size()){
~~~~~~~~~~~~~~
coprobber.cpp:61:13: note: in expansion of macro 'fox'
fox(l, v[a].size()){
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Cop can catch the robber, but start() returned -1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one |
4 |
Halted |
0 ms |
0 KB |
- |