# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
367925 | Kenzo_1114 | Cultivation (JOI17_cultivation) | C++17 | 2 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 310;
int n, m, p, ans = 9;
bool mark[MAXN][MAXN];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
bool valid()
{
bool ok = true;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
ok &= mark[i][j];
return ok;
}
void BKT(int moves)
{
if(moves >= ans) return;
if(valid()) { ans = min(ans, moves); return; }
bool cur[5][5];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cur[i][j] = mark[i][j];
for(int k = 0; k < 4; k++)
{
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
{
int ni = i + dx[k];
int nj = j + dy[k];
mark[i][j] = cur[i][j] || cur[ni][nj];
}
BKT(moves + 1);
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
mark[i][j] = cur[i][j];
}
int main ()
{
scanf("%d %d %d", &n, &m, &p);
for(int i = 0, x, y; i < p; i++)
{
scanf("%d %d", &x, &y);
mark[x][y] = true;
}
if(n <= 4 && m <= 4)
{
BKT(0);
printf("%d\n", ans);
}
else printf("0\n");
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |