제출 #15971

#제출 시각아이디문제언어결과실행 시간메모리
15971gs14004Cop and Robber (BOI14_coprobber)C++14
0 / 100
2 ms384 KiB
#include "coprobber.h"
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;

bool adj[MAX_N][MAX_N];
int indeg[MAX_N][MAX_N][2];

queue<int> qx, qy, qd;
bool vis[500][500][2];
int nxt[500][500];
int pos;

int start(int N, bool A[MAX_N][MAX_N])
{
	memcpy(adj, A, sizeof(A));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (i == j){
				continue;
			}
			for (int k = 0; k < N; k++){
				if (A[j][k]){
					indeg[i][j][0] = 1;
					indeg[i][j][1]++;
				}
			}
		}
	}
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			for (int k = 0; k < 2; k++){
				if (indeg[i][j][k] == 0){
					qx.push(i), qy.push(j), qd.push(k);
					vis[i][j][k] = 1;
				}
			}
		}
	}
	while (!qx.empty()){
		int xf = qx.front();
		int yf = qy.front();
		int df = qd.front();
		qx.pop(), qy.pop(), qd.pop();
		if (df == 1){
			for (int i = 0; i < N; i++){
				if (!vis[i][yf][0]){
					indeg[i][yf][0]--;
					if (indeg[i][yf][0] == 0){
						qx.push(i);
						qy.push(yf);
						qd.push(0);
						vis[i][yf][0] = 1;
						nxt[xf][yf] = i;
					}
				}
			}
		}
		else{
			for (int i = 0; i < N; i++){
				if (!vis[xf][i][1]){
					indeg[xf][i][1]--;
					if (indeg[xf][i][1] == 0){
						qx.push(xf);
						qy.push(i);
						qd.push(1);
						vis[xf][i][1] = 1;
					}
				}
			}
		}
	}
	for (int i = 0; i < N; i++){
		int fnd = 0;
		for (int j = 0; j < N; j++){
			if (!vis[i][j][0]){
				fnd = 1;
				break;
			}
		}
		if (!fnd) return pos = i;
	}
	return -1;
}

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

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

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:17:25: warning: 'sizeof' on array function parameter 'A' will return size of 'bool (*)[500]' [-Wsizeof-array-argument]
  memcpy(adj, A, sizeof(A));
                         ^
coprobber.cpp:15:37: note: declared here
 int start(int N, bool A[MAX_N][MAX_N])
                                     ^
coprobber.cpp:17:23: warning: argument to 'sizeof' in 'void* memcpy(void*, const void*, size_t)' call is the same expression as the source; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
  memcpy(adj, A, sizeof(A));
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...