제출 #107618

#제출 시각아이디문제언어결과실행 시간메모리
107618patrikpavic2경찰관과 강도 (BOI14_coprobber)C++17
0 / 100
5 ms640 KiB
#include "coprobber.h"
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

int mv = 0, pos, n, m;
bool a[MAX_N][MAX_N];

int start(int N, bool A[MAX_N][MAX_N]){
    for(int i = 0;i < MAX_N;i++){
        for(int j = 0;j < MAX_N;j++){
            a[i][j] = A[i][j];
        }
    }
    m = 0;
    while(A[m][m + 1]) m++;m++;
    n = N / m;
    if(n <= 3 && m <= 3){
        if(n == 3 && m == 3)
            return pos = 4;
        return pos = 1;
    }
    else if(n <= 3 || m <= 3){
        if(n <= 3) return pos = m / 2 + (n == 3) * m;
        return pos = N / 2;
    }
    return -1;
}

int nextMove(int R){
    if(a[R][pos]) return R;
    if(n <= 3 && m <= 3) return pos;
    int Rx = R / m, Ry = R % m;
    int Px = pos / m, Py = pos % m;
    if(n <= 3){
        if((Px + Py) % 2 != (Rx + Ry) % 2) return pos;
        if(Py < Ry) return pos = pos + 1;
        return pos = pos - 1;
    }
    if(m <= 3){
        if((Px + Py) % 2 != (Rx + Ry) % 2) return pos;
        if(Px < Rx) return pos = pos + m;
        return pos = pos - m;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:19:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
     while(A[m][m + 1]) m++;m++;
     ^~~~~
coprobber.cpp:19:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
     while(A[m][m + 1]) m++;m++;
                            ^
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...