Submission #365596

# Submission time Handle Problem Language Result Execution time Memory
365596 2021-02-11T22:42:16 Z ly20 Cultivation (JOI17_cultivation) C++17
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
vector <int> v[MAXN];
pair <int, int> g[MAXN];
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);
    int resp = r + c;
    if(r > 40) return 0;
    for(int i = 0; i <= r; i++) {
        for(int j = 0; j <= r; j++) {
            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(v[k].size() == 0) mx = r + c;
                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\n", l, r1, mx);
            resp = min(resp, min(l, r1) + max(l, max(r1, mx)));
        }
    }
    printf("%d\n", resp);
    return 0;
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:29:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                 for(int m = 1; m < v[k].size(); m++) {
      |                                ~~^~~~~~~~~~~~~
cultivation.cpp:17:17: warning: unused variable 'u' [-Wunused-variable]
   17 |             int u = i, d = j;
      |                 ^
cultivation.cpp:17:24: warning: unused variable 'd' [-Wunused-variable]
   17 |             int u = i, d = j;
      |                        ^
cultivation.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d %d", &r, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~
cultivation.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
cultivation.cpp:11:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     for(int i = 0; i < n; i++) scanf("%d %d", &g[i].first, &g[i].second);
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -