답안 #560473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560473 2022-05-11T13:57:05 Z amunduzbaev Cultivation (JOI17_cultivation) C++17
5 / 100
104 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];
	}
	int N = 2 * R + 1, M = 2 * C + 1;
	
	auto check = [&](int a, int b){
		vector<vector<int>> g(N + 1, vector<int>(M + 1));
		vector<vector<int>> t(N + 1, vector<int>(M + 1));
		for(int i=0;i<n;i++){
			g[x[i]][y[i]]++;
			g[x[i] + a][y[i]]--;
			g[x[i]][y[i] + b]--;
			g[x[i] + a][y[i] + b]++;
		}
		
		for(int i=1;i<=N;i++){
			for(int j=1;j<=M;j++){
				g[i][j] += g[i-1][j] + g[i][j-1] - g[i-1][j-1];
				if(g[i][j]) t[i][j] = 1;
				t[i][j] += t[i-1][j] + t[i][j-1] - t[i-1][j-1];
			}
		}
		
		//~ cout<<a<<" "<<b<<"\n";
		//~ for(int i=1;i<=N;i++){
			//~ for(int j=1;j<=M;j++){
				//~ cout<<(g[i][j] > 0)<<" ";
			//~ } cout<<"\n";
		//~ } cout<<"\n";
		for(int i=R;i<=R+a;i++){
			for(int j=C;j<=C+b;j++){
				int cnt = t[i][j] - t[i-R][j] - t[i][j-C] + t[i-R][j-C];
				if(cnt == R * C){
					
					return true;
				}
			}
		}
		return false;
	};
	
	int res = R + C;
	for(int a=1;a<=R;a++){
		for(int b=1;b<=C;b++){
			if(check(a, b)) res = min(res, a + b - 2);
		}
	}
	
	cout<<res<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Correct 46 ms 340 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Incorrect 33 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Correct 46 ms 340 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Incorrect 33 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 104 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 12 ms 340 KB Output is correct
19 Correct 46 ms 340 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Incorrect 33 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -