답안 #1064287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064287 2024-08-18T11:12:27 Z Unforgettablepl Cultivation (JOI17_cultivation) C++17
0 / 100
2 ms 600 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int INF = 1e15;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int r,c,n;
    cin >> r >> c >> n;
    vector<pair<int,int>> points(n);
    for(auto&[a,b]:points)cin>>a>>b;
    auto check = [&](int U,int L){
        vector<vector<int>> lines(r+1);
        for(auto&[x,y]:points) {
            for(int i=max(x-L,1ll);i<=min(i+U,r);i++)lines[i].emplace_back(y);
        }
        int left_maxi = 0;
        int right_maxi = 0;
        int tot_maxi = 0;
        for(int i=1;i<=r;i++) {
            sort(lines[i].begin(),lines[i].end());
            if(lines[i].empty())return INF;
            left_maxi=max(left_maxi,lines[i].front()-1);
            right_maxi=max(right_maxi,c-lines[i].back());
            for(int x=1;x<lines[i].size();x++) {
                tot_maxi=max(tot_maxi,lines[i][x]-lines[i][x-1]-1);
            }
        }
        return max(left_maxi+right_maxi,tot_maxi);
    };
    int ans = r+c;
    for(int R=1;R<r;R++){
        for(int C=1;C<r;C++){
            ans=min(ans,R+C+check(R,C));
        }
    }
    cout << ans << '\n';
}

Compilation message

cultivation.cpp: In lambda function:
cultivation.cpp:28:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int x=1;x<lines[i].size();x++) {
      |                         ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -