Submission #560489

# Submission time Handle Problem Language Result Execution time Memory
560489 2022-05-11T14:12:49 Z amunduzbaev Cultivation (JOI17_cultivation) C++17
5 / 100
1713 ms 262144 KB
#include "bits/stdc++.h"
using namespace std;

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int R, C; cin>>R>>C;
	int n; cin>>n;
	vector<int> x(n), y(n);
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	
	auto check = [&](int a, int c, int b, int d){
		vector<vector<int>> g(R + 1, vector<int>(C + 1));
		for(int i=0;i<n;i++){
			int lx = max(1, x[i] - a), rx = min(R, x[i] + c), ly = max(1, y[i] - b), ry = min(C, y[i] + d);
			g[lx][ly]++;
			if(ry < C) g[lx][ry+1]--;
			if(rx < R) g[rx+1][ly]--;
			if(rx < R && ry < C) g[rx+1][ry+1]++;
		}
		
		for(int i=1;i<=R;i++){
			for(int j=1;j<=C;j++){
				g[i][j] += g[i-1][j] + g[i][j-1] - g[i-1][j-1];
				if(!g[i][j]) return false;
			}
		}
		
		return true;
	};
	
	int res = R + C;
	for(int a=0;a<R;a++){
		for(int b=0;b<C;b++){
			for(int c=0;a+c<R;c++){
				for(int d=0;b+d<C;d++){
					if(check(a, c, b, d)) res = min(res, a + b + c + d);
				}
			}
		}
	}
	
	cout<<res<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 15 ms 316 KB Output is correct
18 Correct 289 ms 296 KB Output is correct
19 Correct 1713 ms 304 KB Output is correct
20 Correct 50 ms 212 KB Output is correct
21 Incorrect 1053 ms 304 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 15 ms 316 KB Output is correct
18 Correct 289 ms 296 KB Output is correct
19 Correct 1713 ms 304 KB Output is correct
20 Correct 50 ms 212 KB Output is correct
21 Incorrect 1053 ms 304 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 103 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 103 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 15 ms 316 KB Output is correct
18 Correct 289 ms 296 KB Output is correct
19 Correct 1713 ms 304 KB Output is correct
20 Correct 50 ms 212 KB Output is correct
21 Incorrect 1053 ms 304 KB Output isn't correct
22 Halted 0 ms 0 KB -