답안 #763040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763040 2023-06-22T02:39:39 Z boyliguanhan 경찰관과 강도 (BOI14_coprobber) C++17
0 / 100
113 ms 8692 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) {
        for(int i = 0; i < n; i++) {
            if(a[r][i] && !dfs(c, i, 0)) {
                vis[c][r][t] = 1;
                inp[c][r][t] = 0;
                return ok[c][r][t] = 0;
            }
        }
        inp[c][r][t] = 0;
        return vis[c][r][t] = ok[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:16:36: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   16 |                 return ok[c][r][t] = 0;
      |                        ~~~~~~~~~~~~^~~
coprobber.cpp:20:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   20 |         return vis[c][r][t] = ok[c][r][t] = 1;
      |                ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
coprobber.cpp:23:69: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   23 |     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:26:60: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   26 |             return move[c][r]=i,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:27:53: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   27 |     return move[c][r]=-1,vis[c][r][t]=1,inp[c][r][t]=0;
      |                                         ~~~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Incorrect 113 ms 8692 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 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 0 ms 464 KB Cop can catch the robber, but start() returned -1
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Incorrect 113 ms 8692 KB Cop can catch the robber, but start() returned -1
5 Halted 0 ms 0 KB -