답안 #59813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59813 2018-07-23T07:16:10 Z 강태규(#1723) Cultivation (JOI17_cultivation) C++11
30 / 100
576 ms 1000 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int inf = 1e9 + 1e3;
int r, c, n;
int x[301];
int y[301];
vector<int> ys[41];

int solve(int u, int d) {
    for (int i = 1; i <= r; ++i) ys[i].clear();
    for (int i = 1; i <= n; ++i) {
        for (int j = max(1, x[i] - u); j <= min(r, x[i] + d); ++j) {
            ys[j].push_back(y[i]);
        }
    }
    int left = 0, right = 0;
    for (int i = 1; i <= r; ++i) {
        if (ys[i].empty()) return inf;
        sort(ys[i].begin(), ys[i].end());
        ys[i].erase(unique(ys[i].begin(), ys[i].end()), ys[i].end());
        left = max(left, ys[i][0] - 1);
        right = max(right, c - ys[i].back());
    }
    int ret = left + right;
    for (int i = 1; i <= r; ++i) {
        for (int j = 1; j < ys[i].size(); ++j) {
            ret = max(ret, ys[i][j] - ys[i][j - 1] - 1);
        }
    }
    return ret;
}

int main() {
    scanf("%d%d%d", &r, &c, &n);
    if (r > 50) return 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", x + i, y + i);
    }
    int ans = inf;
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < r; ++j) {
            ans = min(ans, i + j + solve(i, j));
        }
    }
    printf("%d\n", ans);
	return 0;
}

Compilation message

cultivation.cpp: In function 'int solve(int, int)':
cultivation.cpp:44:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 1; j < ys[i].size(); ++j) {
                         ~~^~~~~~~~~~~~~~
cultivation.cpp: In function 'int main()':
cultivation.cpp:52:10: 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:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", x + i, y + i);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 4 ms 488 KB Output is correct
7 Correct 3 ms 496 KB Output is correct
8 Correct 3 ms 528 KB Output is correct
9 Correct 3 ms 528 KB Output is correct
10 Correct 3 ms 528 KB Output is correct
11 Correct 2 ms 528 KB Output is correct
12 Correct 2 ms 548 KB Output is correct
13 Correct 3 ms 548 KB Output is correct
14 Correct 3 ms 548 KB Output is correct
15 Correct 2 ms 548 KB Output is correct
16 Correct 3 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 4 ms 488 KB Output is correct
7 Correct 3 ms 496 KB Output is correct
8 Correct 3 ms 528 KB Output is correct
9 Correct 3 ms 528 KB Output is correct
10 Correct 3 ms 528 KB Output is correct
11 Correct 2 ms 528 KB Output is correct
12 Correct 2 ms 548 KB Output is correct
13 Correct 3 ms 548 KB Output is correct
14 Correct 3 ms 548 KB Output is correct
15 Correct 2 ms 548 KB Output is correct
16 Correct 3 ms 548 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 18 ms 596 KB Output is correct
19 Correct 17 ms 596 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 44 ms 596 KB Output is correct
22 Correct 166 ms 608 KB Output is correct
23 Correct 25 ms 608 KB Output is correct
24 Correct 309 ms 748 KB Output is correct
25 Correct 225 ms 748 KB Output is correct
26 Correct 506 ms 856 KB Output is correct
27 Correct 488 ms 856 KB Output is correct
28 Correct 310 ms 856 KB Output is correct
29 Correct 428 ms 856 KB Output is correct
30 Correct 503 ms 1000 KB Output is correct
31 Correct 519 ms 1000 KB Output is correct
32 Correct 507 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 4 ms 488 KB Output is correct
7 Correct 3 ms 496 KB Output is correct
8 Correct 3 ms 528 KB Output is correct
9 Correct 3 ms 528 KB Output is correct
10 Correct 3 ms 528 KB Output is correct
11 Correct 2 ms 528 KB Output is correct
12 Correct 2 ms 548 KB Output is correct
13 Correct 3 ms 548 KB Output is correct
14 Correct 3 ms 548 KB Output is correct
15 Correct 2 ms 548 KB Output is correct
16 Correct 3 ms 548 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 18 ms 596 KB Output is correct
19 Correct 17 ms 596 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 44 ms 596 KB Output is correct
22 Correct 166 ms 608 KB Output is correct
23 Correct 25 ms 608 KB Output is correct
24 Correct 309 ms 748 KB Output is correct
25 Correct 225 ms 748 KB Output is correct
26 Correct 506 ms 856 KB Output is correct
27 Correct 488 ms 856 KB Output is correct
28 Correct 310 ms 856 KB Output is correct
29 Correct 428 ms 856 KB Output is correct
30 Correct 503 ms 1000 KB Output is correct
31 Correct 519 ms 1000 KB Output is correct
32 Correct 507 ms 1000 KB Output is correct
33 Correct 3 ms 1000 KB Output is correct
34 Correct 490 ms 1000 KB Output is correct
35 Correct 576 ms 1000 KB Output is correct
36 Correct 549 ms 1000 KB Output is correct
37 Correct 348 ms 1000 KB Output is correct
38 Correct 531 ms 1000 KB Output is correct
39 Correct 492 ms 1000 KB Output is correct
40 Correct 566 ms 1000 KB Output is correct
41 Correct 374 ms 1000 KB Output is correct
42 Correct 404 ms 1000 KB Output is correct
43 Correct 484 ms 1000 KB Output is correct
44 Correct 558 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 4 ms 488 KB Output is correct
7 Correct 3 ms 496 KB Output is correct
8 Correct 3 ms 528 KB Output is correct
9 Correct 3 ms 528 KB Output is correct
10 Correct 3 ms 528 KB Output is correct
11 Correct 2 ms 528 KB Output is correct
12 Correct 2 ms 548 KB Output is correct
13 Correct 3 ms 548 KB Output is correct
14 Correct 3 ms 548 KB Output is correct
15 Correct 2 ms 548 KB Output is correct
16 Correct 3 ms 548 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 18 ms 596 KB Output is correct
19 Correct 17 ms 596 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 44 ms 596 KB Output is correct
22 Correct 166 ms 608 KB Output is correct
23 Correct 25 ms 608 KB Output is correct
24 Correct 309 ms 748 KB Output is correct
25 Correct 225 ms 748 KB Output is correct
26 Correct 506 ms 856 KB Output is correct
27 Correct 488 ms 856 KB Output is correct
28 Correct 310 ms 856 KB Output is correct
29 Correct 428 ms 856 KB Output is correct
30 Correct 503 ms 1000 KB Output is correct
31 Correct 519 ms 1000 KB Output is correct
32 Correct 507 ms 1000 KB Output is correct
33 Correct 3 ms 1000 KB Output is correct
34 Correct 490 ms 1000 KB Output is correct
35 Correct 576 ms 1000 KB Output is correct
36 Correct 549 ms 1000 KB Output is correct
37 Correct 348 ms 1000 KB Output is correct
38 Correct 531 ms 1000 KB Output is correct
39 Correct 492 ms 1000 KB Output is correct
40 Correct 566 ms 1000 KB Output is correct
41 Correct 374 ms 1000 KB Output is correct
42 Correct 404 ms 1000 KB Output is correct
43 Correct 484 ms 1000 KB Output is correct
44 Correct 558 ms 1000 KB Output is correct
45 Incorrect 3 ms 1000 KB Output isn't correct
46 Halted 0 ms 0 KB -