Submission #367925

#TimeUsernameProblemLanguageResultExecution timeMemory
367925Kenzo_1114Cultivation (JOI17_cultivation)C++17
0 / 100
2 ms492 KiB
#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"); }

Compilation message (stderr)

cultivation.cpp: In function 'int main()':
cultivation.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |  scanf("%d %d %d", &n, &m, &p);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cultivation.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   55 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...