답안 #1071303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071303 2024-08-23T06:37:49 Z 김은성(#11136) Cultivation (JOI17_cultivation) C++17
30 / 100
363 ms 752 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1.557e18;
int main(){
	ll r, c, y, x, rd, ru;
	int n, i, j;
	scanf("%lld %lld %d", &r, &c, &n);
	vector<pair<ll, ll> > points;
	for(i=1; i<=n; i++){
		scanf("%lld %lld", &y, &x);
		points.push_back(make_pair(y, x));
	}
	ll ans = INF;
	for(rd=0; rd<=r; rd++){
		for(ru=0; ru<=r; ru++){
			vector<ll> row[45];
			for(auto [y, x]: points){
				for(i=-rd; i<=ru; i++){
					if(1 <= y+i && y+i <= r)
						row[y+i].push_back(x);
				}
			}
			ll cd = 0, cu = 0, sum = 0;
			for(i=1; i<=r; i++){
				sort(row[i].begin(), row[i].end());
				if(row[i].empty()){
					sum = INF;
					break;
				}
				cd = max(cd, row[i].front() - 1);
				cu = max(cu, c - row[i].back());
				for(j=0; j+1<row[i].size(); j++){
					sum = max(sum, row[i][j+1] - row[i][j] - 1);
				}
			}
			ans = min(ans, rd + ru + max(cd+cu, sum));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(j=0; j+1<row[i].size(); j++){
      |              ~~~^~~~~~~~~~~~~~
cultivation.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%lld %lld %d", &r, &c, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cultivation.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%lld %lld", &y, &x);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 12 ms 480 KB Output is correct
19 Correct 14 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 34 ms 464 KB Output is correct
22 Correct 88 ms 504 KB Output is correct
23 Correct 21 ms 344 KB Output is correct
24 Correct 173 ms 532 KB Output is correct
25 Correct 112 ms 524 KB Output is correct
26 Correct 326 ms 628 KB Output is correct
27 Correct 291 ms 624 KB Output is correct
28 Correct 147 ms 344 KB Output is correct
29 Correct 246 ms 616 KB Output is correct
30 Correct 302 ms 624 KB Output is correct
31 Correct 309 ms 628 KB Output is correct
32 Correct 304 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 12 ms 480 KB Output is correct
19 Correct 14 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 34 ms 464 KB Output is correct
22 Correct 88 ms 504 KB Output is correct
23 Correct 21 ms 344 KB Output is correct
24 Correct 173 ms 532 KB Output is correct
25 Correct 112 ms 524 KB Output is correct
26 Correct 326 ms 628 KB Output is correct
27 Correct 291 ms 624 KB Output is correct
28 Correct 147 ms 344 KB Output is correct
29 Correct 246 ms 616 KB Output is correct
30 Correct 302 ms 624 KB Output is correct
31 Correct 309 ms 628 KB Output is correct
32 Correct 304 ms 636 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 340 ms 628 KB Output is correct
35 Correct 325 ms 616 KB Output is correct
36 Correct 342 ms 748 KB Output is correct
37 Correct 204 ms 608 KB Output is correct
38 Correct 363 ms 632 KB Output is correct
39 Correct 307 ms 624 KB Output is correct
40 Correct 336 ms 632 KB Output is correct
41 Correct 158 ms 620 KB Output is correct
42 Correct 224 ms 608 KB Output is correct
43 Correct 273 ms 612 KB Output is correct
44 Correct 330 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 7
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 12 ms 480 KB Output is correct
19 Correct 14 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 34 ms 464 KB Output is correct
22 Correct 88 ms 504 KB Output is correct
23 Correct 21 ms 344 KB Output is correct
24 Correct 173 ms 532 KB Output is correct
25 Correct 112 ms 524 KB Output is correct
26 Correct 326 ms 628 KB Output is correct
27 Correct 291 ms 624 KB Output is correct
28 Correct 147 ms 344 KB Output is correct
29 Correct 246 ms 616 KB Output is correct
30 Correct 302 ms 624 KB Output is correct
31 Correct 309 ms 628 KB Output is correct
32 Correct 304 ms 636 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 340 ms 628 KB Output is correct
35 Correct 325 ms 616 KB Output is correct
36 Correct 342 ms 748 KB Output is correct
37 Correct 204 ms 608 KB Output is correct
38 Correct 363 ms 632 KB Output is correct
39 Correct 307 ms 624 KB Output is correct
40 Correct 336 ms 632 KB Output is correct
41 Correct 158 ms 620 KB Output is correct
42 Correct 224 ms 608 KB Output is correct
43 Correct 273 ms 612 KB Output is correct
44 Correct 330 ms 752 KB Output is correct
45 Runtime error 1 ms 348 KB Execution killed with signal 7
46 Halted 0 ms 0 KB -