Submission #293052

#TimeUsernameProblemLanguageResultExecution timeMemory
293052BTheroCultivation (JOI17_cultivation)C++17
5 / 100
626 ms512 KiB
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; pii arr[305]; int mark[105][105]; int R, C, n; void solve() { scanf("%d %d", &R, &C); scanf("%d", &n); for (int i = 1; i <= n; ++i) { int x, y; scanf("%d %d", &x, &y); arr[i] = mp(x, y); } int ans = R + C; for (int dx = 0; dx <= R - 1; ++dx) { for (int dy = 0; dy <= C - 1; ++dy) { for (int x = 1; x <= 2 * R; ++x) { for (int y = 1; y <= 2 * C; ++y) { mark[x][y] = 0; } } for (int i = 1; i <= n; ++i) { int x1 = arr[i].fi, x2 = arr[i].fi + dx; int y1 = arr[i].se, y2 = arr[i].se + dy; for (int x = x1; x <= x2; ++x) { for (int y = y1; y <= y2; ++y) { mark[x][y] = 1; } } } for (int x1 = 1; x1 <= dx + 1; ++x1) { for (int y1 = 1; y1 <= dy + 1; ++y1) { bool ok = 1; for (int i = 0; i < R; ++i) { for (int j = 0; j < C; ++j) { ok &= mark[x1 + i][y1 + j]; } } if (ok) { ans = min(ans, dx + dy); } } } } } printf("%d\n", ans); } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

cultivation.cpp: In function 'void solve()':
cultivation.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf("%d %d", &R, &C);
      |   ~~~~~^~~~~~~~~~~~~~~~~
cultivation.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
cultivation.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     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...