// ainta & cki86201's code 변형 (https://oj.uz/submission/72484)
#include "sungjin.h"
int X[1010][1010], Y[1010][1010], n, m, vis[1010][1010], U[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;
if(x == 10 && y == 6){
x++; x--;
}
for (int i = 0; i < 4; i++) {
if(!w[x][y][i])DFS(x + dx[i], y + dy[i]);
}
}
int ss = 0;
void Go(int x, int y, int col) {
vis[x][y] = col;
for (int i = 0; i < 4; i++) {
int tx = x + dx[i], ty = y + dy[i];
if(!vis[tx][ty])Go(x + dx[i], y + dy[i], col);
}
}
void Init(int N, int M, int W, int R[], int C[], int dir[]) {
int i, j, res = 0;
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 cnt = 1;
for (i = 1; i <= N; i++) {
for (j = 1; j <= M; j++) {
if (!vis[i][j]) {
cnt++;
ss = 0;
Go(i, j, cnt);
}
}
}
}
int WereSameTerritory(int R1, int C1, int R2, int C2) {
if (vis[R1][C1] == vis[R2][C2] && vis[R1][C1] != 1)return 1;
return 0;
}
// ainta & cki86201's code (https://oj.uz/submission/72484)
#include "dowoon.h"
int w[1010][1010], c1, c2;
void Put(int x, int y, int c) {
if (w[x][y])return;
w[x][y] = c;
if (c == 1)c1++;
else c2++;
}
int Guess(int N, int M) {
int i, j;
for (i = 1; i <= N; i++) {
for (j = 1; j <= M; j++) {
if (c1 * 2 > N*M)return 1;
if (c2 * 2 >= N*M)return 0;
if (w[i][j]) {
if (w[i][j] == 2) continue;
if (j + 1 <= M && !w[i][j + 1]) {
if (Ask(i, j, i, j + 1))Put(i,j+1,1);
else Put(i,j+1,2);
}
if (i + 1 <= N && !w[i + 1][j]) {
if (Ask(i, j, i + 1, j))Put(i+1,j,1);
else Put(i+1,j,2);
}
continue;
}
if (i == N && j == M) {
w[i][j] = 2;
continue;
}
if (i == N) {
if (Ask(i, j, i, j + 1)) {
Put(i, j, 1);
Put(i, j + 1, 1);
}
else Put(i, j, 2);
continue;
}
if (j == M) {
if (Ask(i, j, i + 1, j)) {
Put(i, j, 1);
Put(i + 1, j, 1);
}
else Put(i, j, 2);
continue;
}
int t1 = Ask(i, j, i + 1, j);
int t2 = Ask(i, j, i, j + 1);
if (t1 || t2) {
Put(i, j, 1);
if (t1)Put(i + 1, j, 1);
else Put(i + 1, j, 2);
if (t2)Put(i, j + 1, 1);
else Put(i, j + 1, 2);
}
else {
Put(i, j, 2);
}
}
}
if (c1 * 2 > N*M)return 1;
return 0;
}
Compilation message
sungjin.cpp: In function 'void Init(int, int, int, int*, int*, int*)':
sungjin.cpp:32:12: warning: unused variable 'res' [-Wunused-variable]
int i, j, res = 0;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
920 KB |
Correct |
2 |
Correct |
4 ms |
1336 KB |
Correct |
3 |
Correct |
20 ms |
2000 KB |
Correct |
4 |
Correct |
70 ms |
17968 KB |
Correct |
5 |
Correct |
82 ms |
17968 KB |
Correct |
6 |
Correct |
287 ms |
83592 KB |
Correct |
7 |
Correct |
284 ms |
96876 KB |
Correct |
8 |
Correct |
290 ms |
140228 KB |
Correct |
9 |
Correct |
295 ms |
173016 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
920 KB |
Correct |
2 |
Correct |
4 ms |
1336 KB |
Correct |
3 |
Correct |
20 ms |
2000 KB |
Correct |
4 |
Correct |
70 ms |
17968 KB |
Correct |
5 |
Correct |
82 ms |
17968 KB |
Correct |
6 |
Correct |
287 ms |
83592 KB |
Correct |
7 |
Correct |
284 ms |
96876 KB |
Correct |
8 |
Correct |
290 ms |
140228 KB |
Correct |
9 |
Correct |
295 ms |
173016 KB |
Correct |
10 |
Correct |
869 ms |
173016 KB |
Correct |
11 |
Partially correct |
54 ms |
173016 KB |
Partially correct : C/MN = 1.188 |
12 |
Correct |
30 ms |
173016 KB |
Correct |
13 |
Correct |
11 ms |
173016 KB |
Correct |
14 |
Partially correct |
5 ms |
173016 KB |
Partially correct : C/MN = 1.222 |
15 |
Partially correct |
6 ms |
173016 KB |
Partially correct : C/MN = 1.100 |
16 |
Correct |
5 ms |
173016 KB |
Correct |
17 |
Correct |
5 ms |
173016 KB |
Correct |
18 |
Correct |
4 ms |
173016 KB |
Correct |
19 |
Partially correct |
1408 ms |
175636 KB |
Partially correct : C/MN = 1.120 |
20 |
Correct |
6 ms |
178256 KB |
Correct |
21 |
Correct |
4 ms |
178256 KB |
Correct |
22 |
Correct |
5 ms |
178256 KB |
Correct |
23 |
Correct |
7 ms |
178256 KB |
Correct |
24 |
Correct |
23 ms |
178256 KB |
Correct |
25 |
Runtime error |
13 ms |
178256 KB |
Execution failed because the return code was nonzero |
26 |
Halted |
0 ms |
0 KB |
- |