답안 #62998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62998 2018-07-31T06:57:25 Z gusfring Cultivation (JOI17_cultivation) C++14
5 / 100
2000 ms 860 KB
#include <bits/stdc++.h>
using namespace std;
 
const int MAXR = 42;
const int INF = 1e9;
 
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<R; ++a)
    for(int b=0; b<R; ++b)
      for(int c=0; c<C; ++c)
        for(int d=0; d<C; ++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);
  return 0;
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:15:8: 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:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 4 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 648 KB Output is correct
13 Correct 2 ms 648 KB Output is correct
14 Correct 3 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 4 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 648 KB Output is correct
13 Correct 2 ms 648 KB Output is correct
14 Correct 3 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 338 ms 648 KB Output is correct
18 Execution timed out 2054 ms 732 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 4 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 648 KB Output is correct
13 Correct 2 ms 648 KB Output is correct
14 Correct 3 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 338 ms 648 KB Output is correct
18 Execution timed out 2054 ms 732 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 4 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 3 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 648 KB Output is correct
13 Correct 2 ms 648 KB Output is correct
14 Correct 3 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 338 ms 648 KB Output is correct
18 Execution timed out 2054 ms 732 KB Time limit exceeded
19 Halted 0 ms 0 KB -