답안 #27811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27811 2017-07-14T06:53:57 Z 상수조아(#1181) Cultivation (JOI17_cultivation) C++11
30 / 100
176 ms 1176 KB
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define Fi first
#define Se second

int R, C, N;
pii P[320];

void Do() {
	ll ans = 1e18;
	for(int i=0;i<R;i++) {
		for(int j=0;j<R;j++) {
			int left = 0, right = 0;
			int g = 0;
			int ok = 1;
			for(int r=1;r<=R;r++){
				vector <int> v;
				for(int k=1;k<=N;k++) {
					int x = P[k].Fi, y = P[k].Se;
					if(x-j <= r && r <= x+i) {
						v.pb(y);
					}
				}
				if(sz(v) == 0) { ok = 0; break; }
				left = max(left, v[0] - 1);
				right = max(right, C - v.back());
				for(int i=1;i<sz(v);i++) g = max(g, v[i] - v[i-1] - 1);
			}
			if(ok) {
				ll f = max(g, left + right);
				if(f + i + j < ans) ans = f + i + j;
			}
		}
	}
	printf("%lld\n", ans);
}

int main(){
	scanf("%d%d%d", &R, &C, &N);
	if(R > 40) return 0;
	for(int i=1;i<=N;i++) scanf("%d%d", &P[i].Fi, &P[i].Se);
	sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; });
	Do();
	return 0;
};

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:50:29: 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:52:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=N;i++) scanf("%d%d", &P[i].Fi, &P[i].Se);
                                                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1176 KB Output is correct
2 Correct 0 ms 1176 KB Output is correct
3 Correct 0 ms 1176 KB Output is correct
4 Correct 0 ms 1176 KB Output is correct
5 Correct 0 ms 1176 KB Output is correct
6 Correct 0 ms 1176 KB Output is correct
7 Correct 0 ms 1176 KB Output is correct
8 Correct 0 ms 1176 KB Output is correct
9 Correct 0 ms 1176 KB Output is correct
10 Correct 0 ms 1176 KB Output is correct
11 Correct 0 ms 1176 KB Output is correct
12 Correct 0 ms 1176 KB Output is correct
13 Correct 0 ms 1176 KB Output is correct
14 Correct 0 ms 1176 KB Output is correct
15 Correct 0 ms 1176 KB Output is correct
16 Correct 0 ms 1176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1176 KB Output is correct
2 Correct 0 ms 1176 KB Output is correct
3 Correct 0 ms 1176 KB Output is correct
4 Correct 0 ms 1176 KB Output is correct
5 Correct 0 ms 1176 KB Output is correct
6 Correct 0 ms 1176 KB Output is correct
7 Correct 0 ms 1176 KB Output is correct
8 Correct 0 ms 1176 KB Output is correct
9 Correct 0 ms 1176 KB Output is correct
10 Correct 0 ms 1176 KB Output is correct
11 Correct 0 ms 1176 KB Output is correct
12 Correct 0 ms 1176 KB Output is correct
13 Correct 0 ms 1176 KB Output is correct
14 Correct 0 ms 1176 KB Output is correct
15 Correct 0 ms 1176 KB Output is correct
16 Correct 0 ms 1176 KB Output is correct
17 Correct 0 ms 1176 KB Output is correct
18 Correct 9 ms 1176 KB Output is correct
19 Correct 19 ms 1176 KB Output is correct
20 Correct 0 ms 1176 KB Output is correct
21 Correct 29 ms 1176 KB Output is correct
22 Correct 59 ms 1176 KB Output is correct
23 Correct 19 ms 1176 KB Output is correct
24 Correct 99 ms 1176 KB Output is correct
25 Correct 76 ms 1176 KB Output is correct
26 Correct 133 ms 1176 KB Output is correct
27 Correct 139 ms 1176 KB Output is correct
28 Correct 99 ms 1176 KB Output is correct
29 Correct 126 ms 1176 KB Output is correct
30 Correct 139 ms 1176 KB Output is correct
31 Correct 149 ms 1176 KB Output is correct
32 Correct 176 ms 1176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1176 KB Output is correct
2 Correct 0 ms 1176 KB Output is correct
3 Correct 0 ms 1176 KB Output is correct
4 Correct 0 ms 1176 KB Output is correct
5 Correct 0 ms 1176 KB Output is correct
6 Correct 0 ms 1176 KB Output is correct
7 Correct 0 ms 1176 KB Output is correct
8 Correct 0 ms 1176 KB Output is correct
9 Correct 0 ms 1176 KB Output is correct
10 Correct 0 ms 1176 KB Output is correct
11 Correct 0 ms 1176 KB Output is correct
12 Correct 0 ms 1176 KB Output is correct
13 Correct 0 ms 1176 KB Output is correct
14 Correct 0 ms 1176 KB Output is correct
15 Correct 0 ms 1176 KB Output is correct
16 Correct 0 ms 1176 KB Output is correct
17 Correct 0 ms 1176 KB Output is correct
18 Correct 9 ms 1176 KB Output is correct
19 Correct 19 ms 1176 KB Output is correct
20 Correct 0 ms 1176 KB Output is correct
21 Correct 29 ms 1176 KB Output is correct
22 Correct 59 ms 1176 KB Output is correct
23 Correct 19 ms 1176 KB Output is correct
24 Correct 99 ms 1176 KB Output is correct
25 Correct 76 ms 1176 KB Output is correct
26 Correct 133 ms 1176 KB Output is correct
27 Correct 139 ms 1176 KB Output is correct
28 Correct 99 ms 1176 KB Output is correct
29 Correct 126 ms 1176 KB Output is correct
30 Correct 139 ms 1176 KB Output is correct
31 Correct 149 ms 1176 KB Output is correct
32 Correct 176 ms 1176 KB Output is correct
33 Correct 0 ms 1176 KB Output is correct
34 Correct 129 ms 1176 KB Output is correct
35 Correct 139 ms 1176 KB Output is correct
36 Correct 139 ms 1176 KB Output is correct
37 Correct 96 ms 1176 KB Output is correct
38 Correct 146 ms 1176 KB Output is correct
39 Correct 153 ms 1176 KB Output is correct
40 Correct 133 ms 1176 KB Output is correct
41 Correct 126 ms 1176 KB Output is correct
42 Correct 146 ms 1176 KB Output is correct
43 Correct 146 ms 1176 KB Output is correct
44 Correct 139 ms 1176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1176 KB Output is correct
2 Correct 0 ms 1176 KB Output is correct
3 Correct 0 ms 1176 KB Output is correct
4 Correct 0 ms 1176 KB Output is correct
5 Correct 0 ms 1176 KB Output is correct
6 Correct 0 ms 1176 KB Output is correct
7 Correct 0 ms 1176 KB Output is correct
8 Correct 0 ms 1176 KB Output is correct
9 Correct 0 ms 1176 KB Output is correct
10 Correct 0 ms 1176 KB Output is correct
11 Correct 0 ms 1176 KB Output is correct
12 Correct 0 ms 1176 KB Output is correct
13 Correct 0 ms 1176 KB Output is correct
14 Correct 0 ms 1176 KB Output is correct
15 Correct 0 ms 1176 KB Output is correct
16 Correct 0 ms 1176 KB Output is correct
17 Correct 0 ms 1176 KB Output is correct
18 Correct 9 ms 1176 KB Output is correct
19 Correct 19 ms 1176 KB Output is correct
20 Correct 0 ms 1176 KB Output is correct
21 Correct 29 ms 1176 KB Output is correct
22 Correct 59 ms 1176 KB Output is correct
23 Correct 19 ms 1176 KB Output is correct
24 Correct 99 ms 1176 KB Output is correct
25 Correct 76 ms 1176 KB Output is correct
26 Correct 133 ms 1176 KB Output is correct
27 Correct 139 ms 1176 KB Output is correct
28 Correct 99 ms 1176 KB Output is correct
29 Correct 126 ms 1176 KB Output is correct
30 Correct 139 ms 1176 KB Output is correct
31 Correct 149 ms 1176 KB Output is correct
32 Correct 176 ms 1176 KB Output is correct
33 Correct 0 ms 1176 KB Output is correct
34 Correct 129 ms 1176 KB Output is correct
35 Correct 139 ms 1176 KB Output is correct
36 Correct 139 ms 1176 KB Output is correct
37 Correct 96 ms 1176 KB Output is correct
38 Correct 146 ms 1176 KB Output is correct
39 Correct 153 ms 1176 KB Output is correct
40 Correct 133 ms 1176 KB Output is correct
41 Correct 126 ms 1176 KB Output is correct
42 Correct 146 ms 1176 KB Output is correct
43 Correct 146 ms 1176 KB Output is correct
44 Correct 139 ms 1176 KB Output is correct
45 Incorrect 0 ms 1176 KB Output isn't correct
46 Halted 0 ms 0 KB -