#include "sungjin.h"
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
static int N, M;
static bool vis[1010][1010];
static int kabe[1010][1010];
void dfs(int r, int c)
{
if(r<0 || r>N+1 || c<0 || c>M+1) return;
if(vis[r][c]) return;
vis[r][c] = true;
for(int d=0; d<4; ++d)
{
if(kabe[r][c]&(1<<d)) continue;
dfs(r+dx[d], c+dy[d]);
}
return;
}
void Init(int N, int M, int W, int R[], int C[], int dir[]) {
::N=N; ::M=M;
for(int i=0; i<W; ++i)
{
int nx = R[i], ny = C[i], nd = dir[i]-1;
int px = R[i]+dx[nd], py = C[i]+dy[nd], pd = nd^1;
kabe[nx][ny] |= (1<<nd);
kabe[px][py] |= (1<<pd);
//printf("%d %d %d %d %d %d \n", nx, ny, nd, px ,py,pd);
}
dfs(0, 0);
/*for(int i=1; i<=N; ++i)
for(int j=1; j<=N; ++j)
if(!vis[i][j]) printf("(%d, %d)\n", i, j);
*/
}
int WereSameTerritory(int R1, int C1, int R2, int C2) {
return !vis[R1][C1] && !vis[R2][C2];
}
#include "dowoon.h"
static int N, M;
int ask(int x, int y)
{
return Ask(x/N+1, x%N+1, y/N+1, y%N+1);
}
int Guess(int N, int M) {
return 0;
::N = N, ::M = M; int C = N*M;
int ged = -1;
for(int i=0; i<(C+1)/2; ++i)
{
int v1 = 2*i+1, v2 = 2*i;
if(C==v1) v1 = 0;
if(ask(v1, v2))
ged = v1;
}
if(ged==-1) return 0;
int cnt = 1;
for(int i=0; i<C; ++i)
{
if(i==ged) continue;
cnt += ask(i, ged);
}
if(cnt > C/2) return 1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
752 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
752 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |