#include "sungjin.h"
int X[1010][1010], Y[1010][1010], n, m, vis[1010][1010];
int w[1010][1010][4], dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };
int Rev[4] = { 1,0,3,2 };
void DFS(int x, int y) {
if (x<0 || y<0 || x>n + 1 || y>m + 1 || vis[x][y])return;
vis[x][y] = 1;
for (int i = 0; i < 4; i++) {
if(!w[x][y][i])DFS(x + dx[i], y + dy[i]);
}
}
void Init(int N, int M, int W, int R[], int C[], int dir[]) {
int i, j;
n = N, m = M;
for (i = 0; i < W; i++) {
dir[i]--;
w[R[i]][C[i]][dir[i]] = 1;
w[R[i]+dx[dir[i]]][C[i]+dy[dir[i]]][Rev[dir[i]]] = 1;
}
DFS(0, 0);
}
int WereSameTerritory(int R1, int C1, int R2, int C2) {
if (!vis[R1][C1] && !vis[R2][C2])return 1;
return 0;
}
#include "dowoon.h"
int w[1010][1010];
int Guess(int N, int M) {
int i, j;
for (i = 1; i <= N; i++) {
for (j = 1; j < M; j++) {
if (Ask(i, j, i, j + 1))w[i][j] = w[i][j+1]=1;
}
}
for (i = 1; i < N; i++) {
for (j = 1; j <= M; j++) {
if (Ask(i, j, i + 1, j))w[i][j] = w[i + 1][j] = 1;
}
}
int res = 0;
for (i = 1; i <= N; i++)for (j = 1; j <= M; j++) {
if (w[i][j])res++;
}
if (res * 2 > M*N)return 1;
return 0;
}
Compilation message
sungjin.cpp: In function 'void Init(int, int, int, int*, int*, int*)':
sungjin.cpp:18:9: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
868 KB |
Correct |
2 |
Correct |
4 ms |
1232 KB |
Correct |
3 |
Correct |
19 ms |
1712 KB |
Correct |
4 |
Correct |
89 ms |
17936 KB |
Correct |
5 |
Correct |
89 ms |
17936 KB |
Correct |
6 |
Correct |
273 ms |
82324 KB |
Correct |
7 |
Correct |
270 ms |
95352 KB |
Correct |
8 |
Correct |
337 ms |
138336 KB |
Correct |
9 |
Correct |
359 ms |
169264 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
868 KB |
Correct |
2 |
Correct |
4 ms |
1232 KB |
Correct |
3 |
Correct |
19 ms |
1712 KB |
Correct |
4 |
Correct |
89 ms |
17936 KB |
Correct |
5 |
Correct |
89 ms |
17936 KB |
Correct |
6 |
Correct |
273 ms |
82324 KB |
Correct |
7 |
Correct |
270 ms |
95352 KB |
Correct |
8 |
Correct |
337 ms |
138336 KB |
Correct |
9 |
Correct |
359 ms |
169264 KB |
Correct |
10 |
Partially correct |
803 ms |
169264 KB |
Partially correct : C/MN = 1.550 |
11 |
Partially correct |
48 ms |
169264 KB |
Partially correct : C/MN = 1.500 |
12 |
Partially correct |
28 ms |
169264 KB |
Partially correct : C/MN = 1.467 |
13 |
Partially correct |
7 ms |
169264 KB |
Partially correct : C/MN = 1.417 |
14 |
Partially correct |
6 ms |
169264 KB |
Partially correct : C/MN = 1.333 |
15 |
Partially correct |
6 ms |
169264 KB |
Partially correct : C/MN = 1.300 |
16 |
Partially correct |
4 ms |
169264 KB |
Partially correct : C/MN = 1.250 |
17 |
Partially correct |
5 ms |
169264 KB |
Partially correct : C/MN = 1.167 |
18 |
Correct |
4 ms |
169264 KB |
Correct |
19 |
Partially correct |
1297 ms |
173732 KB |
Partially correct : C/MN = 1.600 |
20 |
Correct |
6 ms |
178200 KB |
Correct |
21 |
Runtime error |
2 ms |
89100 KB |
Execution failed because the return code was nonzero |
22 |
Halted |
0 ms |
0 KB |
- |