답안 #365598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365598 2021-02-11T22:59:02 Z ly20 Cultivation (JOI17_cultivation) C++17
5 / 100
1 ms 500 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
vector <int> v[MAXN];
pair <int, int> g[MAXN];
bool cmp(pair <int, int> a, pair <int, int> b) {
    //if(a.second == b.second) return a.first < b.first;
    return a.second < b.second;
}
int main() {
    int r, c;
    scanf("%d %d", &r, &c);
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d %d", &g[i].first, &g[i].second);
    sort(g, g + n, cmp);
    int resp = r + c;
    if(r > 40) return 0;
    for(int i = 0; i <= r; i++) {
        for(int j = 0; j <= r; j++) {
            for(int k = 0; k <= r; k++) v[k].clear();
            int u = i, d = j;
            for(int k = 0; k < n; k++) {
                int a = max(1, g[k].first - i), b = min(r, g[k].first + j);
                for(int l = a; l <= b; l++) v[l].push_back(g[k].second);
            }
            int l = 0, r1 = 0, mx = 0;
            for(int k = 1; k <= r; k++) {
                //printf("oi\n");
                //if(i == 0 && j == 2) printf("%d\n", v[k][v[k].size() - 1]);
                if(v[k].size() == 0) mx = 1123456789;
                if(v[k].size() == 0) continue;
                l = max(l, v[k][0] - 1);
                r1 = max(r1, c - v[k][v[k].size() - 1]);
                for(int m = 1; m < v[k].size(); m++) {
                    mx = max(v[k][m] - v[k][m - 1] - 1, mx);
                }
            }
            //printf("%d %d %d %d %d\n", i, j, l, r1, mx);
            resp = min(resp, min(l, r1) + max(l, max(r1, mx)) + i + j);
        }
    }
    printf("%d\n", resp);
    return 0;
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:35:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                 for(int m = 1; m < v[k].size(); m++) {
      |                                ~~^~~~~~~~~~~~~
cultivation.cpp:22:17: warning: unused variable 'u' [-Wunused-variable]
   22 |             int u = i, d = j;
      |                 ^
cultivation.cpp:22:24: warning: unused variable 'd' [-Wunused-variable]
   22 |             int u = i, d = j;
      |                        ^
cultivation.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d %d", &r, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~
cultivation.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
cultivation.cpp:15:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     for(int i = 0; i < n; i++) scanf("%d %d", &g[i].first, &g[i].second);
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB Output isn't correct
18 Halted 0 ms 0 KB -