Submission #293661

# Submission time Handle Problem Language Result Execution time Memory
293661 2020-09-08T09:18:09 Z BThero Cultivation (JOI17_cultivation) C++17
5 / 100
2000 ms 384 KB
// 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;

int mark[45][45];
pii arr[305];
int n, R, C;

void solve() {
  scanf("%d %d", &R, &C);
  scanf("%d", &n);
  
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &arr[i].fi, &arr[i].se);
  }
  
  int ans = R + C;
  
  for (int ax = 0; ax <= R; ++ax) {
    for (int bx = 0; ax + bx <= R; ++bx) {
      for (int ay = 0; ay <= C; ++ay) {
        for (int by = 0; ay + by <= C; ++by) {
          int cur = ax + bx + ay + by;
          
          if (cur >= ans) {
            continue;
          }
        
          for (int i = 1; i <= n; ++i) {
            int x1 = max(1, arr[i].fi - ax);
            int x2 = min(R, arr[i].fi + bx);
            int y1 = max(1, arr[i].se - ay);
            int y2 = min(C, arr[i].se + by);
            
            for (int x = x1; x <= x2; ++x) {
              for (int y = y1; y <= y2; ++y) {
                mark[x][y] = 1;
              }
            }
          }
          
          bool ok = 1;
          
          for (int x = 1; x <= R; ++x) {
            for (int y = 1; y <= C; ++y) {
              ok &= mark[x][y];
              mark[x][y] = 0;
            }
          } 
          
          if (ok) {
            ans = cur;
          }
        }
      }
    }
  }
  
  printf("%d\n", ans);
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}

Compilation message

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:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d %d", &arr[i].fi, &arr[i].se);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 746 ms 376 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Execution timed out 2074 ms 256 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 746 ms 376 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Execution timed out 2074 ms 256 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 746 ms 376 KB Output is correct
20 Correct 13 ms 384 KB Output is correct
21 Execution timed out 2074 ms 256 KB Time limit exceeded
22 Halted 0 ms 0 KB -