답안 #550680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550680 2022-04-18T19:52:40 Z LucaDantas Cultivation (JOI17_cultivation) C++17
30 / 100
875 ms 916 KB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxr = 41, maxn = 310, inf = 0x3f3f3f3f;

int n, r, c;

set<int> mark[maxr]; // salvo pra cada linha quais colunas tão ativas

struct par {
    int r, c;
} pares[maxn];

int get() {
    // Calculo a resposta separadamente pra cada linha

    int minSum = 0, minL = 0, minR = 0;
    for(int row = 0; row < r; row++) {
        if(!mark[row].size()) return inf; // pessimo
        minL = max(minL, *mark[row].begin());
        minR = max(minR, c-1 - *mark[row].rbegin());
        for(auto it = mark[row].begin(); next(it) != mark[row].end(); ++it)
            minSum = max(minSum, *next(it) - *it - 1);
    }

    return max(minSum, minL + minR);
}

int main() {
    scanf("%d %d", &r, &c);
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d %d", &pares[i].r, &pares[i].c), --pares[i].r, --pares[i].c;

    int ans = inf;
    for(int cima = 0; cima < r; cima++) {
        // painting
    
        for(int i = 0; i < r; i++)
            mark[i].clear();

        for(int i = 0; i < n; i++)
            mark[pares[i].r].insert(pares[i].c);

        for(int row = 1; row < r; row++)
            for(int j = 1; j <= cima && row - j >= 0; j++)
                for(int coluna : mark[row])
                        mark[row-j].insert(coluna);

        for(int baixo = 0; baixo < r; baixo++) {
            ans = min(ans, cima + baixo + get());

            for(int row = r-2; row >= 0; row--)
                for(int coluna : mark[row])
                    mark[row+1].insert(coluna);
        }
    }
    
    printf("%d\n", ans);
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf("%d %d", &r, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~
cultivation.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
cultivation.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%d %d", &pares[i].r, &pares[i].c), --pares[i].r, --pares[i].c;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 11 ms 308 KB Output is correct
19 Correct 18 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 344 KB Output is correct
22 Correct 106 ms 360 KB Output is correct
23 Correct 31 ms 328 KB Output is correct
24 Correct 110 ms 356 KB Output is correct
25 Correct 100 ms 352 KB Output is correct
26 Correct 106 ms 368 KB Output is correct
27 Correct 121 ms 340 KB Output is correct
28 Correct 102 ms 372 KB Output is correct
29 Correct 121 ms 364 KB Output is correct
30 Correct 116 ms 340 KB Output is correct
31 Correct 114 ms 372 KB Output is correct
32 Correct 126 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 11 ms 308 KB Output is correct
19 Correct 18 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 344 KB Output is correct
22 Correct 106 ms 360 KB Output is correct
23 Correct 31 ms 328 KB Output is correct
24 Correct 110 ms 356 KB Output is correct
25 Correct 100 ms 352 KB Output is correct
26 Correct 106 ms 368 KB Output is correct
27 Correct 121 ms 340 KB Output is correct
28 Correct 102 ms 372 KB Output is correct
29 Correct 121 ms 364 KB Output is correct
30 Correct 116 ms 340 KB Output is correct
31 Correct 114 ms 372 KB Output is correct
32 Correct 126 ms 364 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 695 ms 892 KB Output is correct
35 Correct 641 ms 916 KB Output is correct
36 Correct 850 ms 852 KB Output is correct
37 Correct 588 ms 768 KB Output is correct
38 Correct 875 ms 852 KB Output is correct
39 Correct 822 ms 864 KB Output is correct
40 Correct 863 ms 880 KB Output is correct
41 Correct 532 ms 828 KB Output is correct
42 Correct 496 ms 676 KB Output is correct
43 Correct 786 ms 844 KB Output is correct
44 Correct 540 ms 744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 11 ms 308 KB Output is correct
19 Correct 18 ms 328 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 344 KB Output is correct
22 Correct 106 ms 360 KB Output is correct
23 Correct 31 ms 328 KB Output is correct
24 Correct 110 ms 356 KB Output is correct
25 Correct 100 ms 352 KB Output is correct
26 Correct 106 ms 368 KB Output is correct
27 Correct 121 ms 340 KB Output is correct
28 Correct 102 ms 372 KB Output is correct
29 Correct 121 ms 364 KB Output is correct
30 Correct 116 ms 340 KB Output is correct
31 Correct 114 ms 372 KB Output is correct
32 Correct 126 ms 364 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 695 ms 892 KB Output is correct
35 Correct 641 ms 916 KB Output is correct
36 Correct 850 ms 852 KB Output is correct
37 Correct 588 ms 768 KB Output is correct
38 Correct 875 ms 852 KB Output is correct
39 Correct 822 ms 864 KB Output is correct
40 Correct 863 ms 880 KB Output is correct
41 Correct 532 ms 828 KB Output is correct
42 Correct 496 ms 676 KB Output is correct
43 Correct 786 ms 844 KB Output is correct
44 Correct 540 ms 744 KB Output is correct
45 Runtime error 1 ms 340 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -