제출 #320904

#제출 시각아이디문제언어결과실행 시간메모리
320904shrek12357경찰관과 강도 (BOI14_coprobber)C++14
16 / 100
169 ms262148 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
#include "coprobber.h"
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0); 

const int MAXN = 505;

bool found[MAXN][MAXN];
vector<int> adjList[MAXN];
int cur = 0, par = 0;

void dfs(int src, int par) {
	found[src][src] = true;
	for (auto i : adjList[src]) {
		if (i == par) {
			continue;
		}
		dfs(i, src);
		for (int j = 0; j < MAXN; j++) {
			found[src][j] |= found[i][j];
		}
	}
}

int start(int N, bool A[MAX_N][MAX_N]) {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[i][j]) {
				adjList[i].push_back(j);
			}
		}
	}
	dfs(0, 0);
	return cur;
}

int nextMove(int R) {
	if (cur == R) {
		return R;
	}
	for (auto i : adjList[cur]) {
		if (i == par) {
			continue;
		}
		if (found[i][R]) {
			par = cur;
			cur = i;
			return cur;
		}
	}
}

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

coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...