답안 #35365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
35365 2017-11-20T19:00:49 Z pedro_sponchiado Cultivation (JOI17_cultivation) C++14
0 / 100
0 ms 2084 KB
#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;	
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<comp_x.size(); i++){
                ^
cultivation.cpp:17:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &r, &c, &n);
                               ^
cultivation.cpp:20:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a, &b);
                         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2084 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 2084 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2084 KB Output isn't correct
2 Halted 0 ms 0 KB -