Submission #762994

# Submission time Handle Problem Language Result Execution time Memory
762994 2023-06-22T02:14:10 Z vjudge1 Cop and Robber (BOI14_coprobber) C++17
0 / 100
158 ms 8724 KB
#include "coprobber.h"
#pragma GCC optimize(2)
int ok[MAX_N][MAX_N][2], move[MAX_N][MAX_N], vis[MAX_N][MAX_N][2], inp[MAX_N][MAX_N][2], n;
bool a[MAX_N][MAX_N];
int pos;
bool dfs(int c, int r, int t) {
    if(c==r) return ok[c][r][t]=1;
    if(inp[c][r][t]) return 0;
    if(vis[c][r][t]) return ok[c][r][t];
    inp[c][r][t] = 1;
    if(t) {
        ok[c][r][t] = 1;
        for(int i = 0; i < n; i++)
            if(a[r][i]&&!dfs(c,i,0))
                return vis[c][r][t]=1,inp[c][r][t]=ok[c][r][t]=0;
        return inp[c][r][t]=0,vis[c][r][t]=1;
    }
    if(dfs(c,r,1)) return move[c][r] = c,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
    for(int i = 0; i < n; i++)
        if(a[c][i]&&dfs(i,r,1))
            return move[c][r]=i,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
    return move[c][r]=-1,vis[c][r][t]=1,inp[c][r][t]=0;
}
int start(int N, bool A[MAX_N][MAX_N])
{
    n = N;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            a[i][j] = A[i][j];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            dfs(i,j,0);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(move[i][j]==-1) break;
            if(j==n-1) return pos = i;
        }
    }
    return -1;
}

int nextMove(int R)
{
    return pos=move[pos][R];
}

Compilation message

coprobber.cpp: In function 'bool dfs(int, int, int)':
coprobber.cpp:7:32: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    7 |     if(c==r) return ok[c][r][t]=1;
      |                     ~~~~~~~~~~~^~
coprobber.cpp:15:51: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   15 |                 return vis[c][r][t]=1,inp[c][r][t]=ok[c][r][t]=0;
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:16:43: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   16 |         return inp[c][r][t]=0,vis[c][r][t]=1;
      |                               ~~~~~~~~~~~~^~
coprobber.cpp:18:69: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   18 |     if(dfs(c,r,1)) return move[c][r] = c,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
      |                                                         ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:21:60: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   21 |             return move[c][r]=i,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:22:53: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |     return move[c][r]=-1,vis[c][r][t]=1,inp[c][r][t]=0;
      |                                         ~~~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Incorrect 158 ms 8724 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 0 ms 464 KB Cop can catch the robber, but start() returned -1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 284 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Incorrect 1 ms 464 KB Cop can catch the robber, but start() returned -1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Incorrect 158 ms 8724 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -