답안 #413473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413473 2021-05-28T19:09:44 Z Blagojce 경찰관과 강도 (BOI14_coprobber) C++11
0 / 100
1 ms 328 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
  
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
const ll inf = 1e18;
const int i_inf = 1e9;
const ll mod = 1e9+7;
  
const int mxn = 2e5+5;


#include "coprobber.h"


int deg[505];

int n, m;

int r[505];
int c[505];

int mat[505][505];

int start(int N, bool A[MAX_N][MAX_N])
{
	fr(i, 0, N){
		fr(j, 0, N){
			if(A[i][j]) deg[i]++;
		}
	}
	int f = 0;
	
	fr(i, 1, N){
		if(deg[i] == 2){
			f = i;
			break;
		}
	}
	m = f+1;
	
	n = N/m;
	
	int id = 0;
	fr(i, 0, n){
		fr(j, 0, m){
			++id;
			r[id] = i;
			c[id] = j;
			mat[i][j] = id;
		}
	}
	return 0;
}

int cop = 0;

int nextMove(int R)
{
	if(r[cop] - r[R] > 1){
		cop = mat[r[cop]-1][c[cop]];
		return cop;
	}
	if(r[R] - r[cop] > 1){
		cop = mat[r[cop]+1][c[cop]];
		return cop;
	}
	
	if(c[cop] - c[R] > 1){
		cop = mat[r[cop]][c[cop]-1];
		return cop;
	}
	if(c[R] - c[cop] > 1){
		cop = mat[r[cop]][c[cop]+1];
		return cop;
	}
	
	if(abs(r[R]-r[cop]) == 1 && abs(c[R]-c[cop])) return cop;
	else return R;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 1 ms 328 KB nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 1 ms 292 KB nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 1 ms 328 KB nextMove() returned a value that is either outside 0..N-1 or the new cop position is not a neighbour to the previous one
4 Halted 0 ms 0 KB -