제출 #35361

#제출 시각아이디문제언어결과실행 시간메모리
35361gabrielsimoesCultivation (JOI17_cultivation)C++14
5 / 100
2000 ms2020 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXR = 42;
const int INF = 1e9 + 10;

typedef pair<int, int> pii;
#define x first
#define y second

int R, C, n;
vector<pii> v;

int main() {
  scanf("%d %d %d", &R, &C, &n);

  assert(R <= 40 && C <= 40);

  for (int i = 0, x, y; i < n; i++) {
    scanf("%d %d", &x, &y);
    v.push_back(pii(x, y));
  }

  int ans = INF;
  for (int a = 0; a < 40; a++) {
    for (int b = 0; b < 40; b++) {
      for (int c = 0; c < 40; c++) {
        for (int d = 0; d < 40; d++) {
          bool bad = 0;
          for (int x = 1; x <= R && !bad; x++) {
            for (int y = 1; y <= C; y++) {
              bool ok = 0;
              for (pii p : v) {
                if (((p.x < x && x - p.x <= a) || (p.x >= x && p.x - x <= b)) &&
                    ((p.y < y && y - p.y <= c) || (p.y >= y && p.y - y <= d)))
                  ok = 1;
              }
              if (!ok) {
                bad = 1;
                break;
              }
            }
          }
          if (!bad) ans = min(ans, a + b + c + d);
        }
      }
    }
  }

  printf("%d\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

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