# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
35365 | pedro_sponchiado | Cultivation (JOI17_cultivation) | C++14 | 0 ms | 2084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn=310;
const int INF=2000000010;
int n, x[maxn], y[maxn], r, c, a, b;
int y_x[maxn];
int x_x[maxn];
vector<pair<int, int> > comp_x;
int marc[maxn][50];
int main(){
scanf("%d %d %d", &r, &c, &n);
for(int i=1; i<=n; i++){
scanf("%d %d", &a, &b);
comp_x.push_back(make_pair(b, a));
}
sort(comp_x.begin(), comp_x.end());
for(int i=0; i<comp_x.size(); i++){
x[i+1]=comp_x[i].first;
y[i+1]=comp_x[i].second;
// printf("%d %d\n", x[i+1], y[i+1]);
}
int resp=INF+10;
for(int cima=0; cima<=r; cima++){
for(int baixo=0; baixo<=r; baixo++){
for(int i=1; i<=n; i++){
for(int j=1; j<=r; j++){
marc[i][j]=0;
}
}
for(int i=1; i<=n; i++){
for(int j=0; j<=cima; j++){
if(y[i]+j<=r) marc[i][y[i]+j]=1;
}
for(int j=1; j<=baixo; j++){
if(y[i]-j>=0) marc[i][y[i]-j]=1;
}
}
/*for(int i=1; i<=r; i++){
for(int j=1; j<=c; j++){
printf("%d ", marc[j][i]);
}
printf("\n");
}
printf("\n");*/
int maxi=0;
int maxi_c=0;
int maxi_f=0;
int t=0;
for(int j=1; j<=r; j++){
int acumulado=0;
for(int i=1; i<=n; i++){
if(marc[i][j]==0) acumulado+=x[i]-x[i-1];
else if(marc[i][j]==1){
acumulado+=x[i]-x[i-1]-1;
if(i==1) maxi_c=max(maxi_c, x[i]-1);
else if(i==n) maxi_f=max(maxi_f, c-x[i]);
else maxi=max(maxi, acumulado);
}
}
if(acumulado==c){
t=1;
break;
}
}
if(t) break;
resp=min(resp, cima+baixo+max(maxi, maxi_c+maxi_f));
}
}
printf("%d\n", resp);
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... |