# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
62999 | gusfring | Cultivation (JOI17_cultivation) | C++14 | 562 ms | 1176 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 305, inf = 1e9;
int n, R, C;
pii p[maxn];
vector<int> have[45];
int main(){
scanf("%d %d %d", &R, &C, &n);
for(int i=1; i<=n; ++i) scanf("%d%d",&p[i].X,&p[i].Y);
int ans = inf;
for(int up=0; up<=R; ++up)
for(int down=0; down<=R; ++down){
for(int row=1; row<=R; ++row) have[row].clear();
for(int x=1; x<=n; x++)
for(int i=max(1,p[x].X-up); i<=min(R,p[x].X+down); ++i) have[i].push_back(p[x].Y);
for(int row=1; row<=R; ++row) sort(have[row].begin(), have[row].end());
int left = 0, right = 0, gap = 0, bad = 0;
for(int row=1; row<=R; ++row){
if(have[row].size()==0){ bad = 1; break; }
left = max(left, *have[row].begin()-1); right = max(right, C-*have[row].rbegin());
}
for(int row=1; row<=R; ++row)
for(int i=1; i<have[row].size(); ++i)
gap = max(gap, have[row][i]-have[row][i-1]-1-left-right);
if(!bad) ans = min(ans, up + down + left + right + gap);
}
printf("%d",ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |