답안 #1071177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071177 2024-08-23T05:37:08 Z sleepntsheep Cultivation (JOI17_cultivation) C++17
5 / 100
229 ms 404 KB
#pragma GCC optimize("O3,unroll-loops")
#include <cstdio>

#include <algorithm>
using namespace std;

int C,z=1e9,R, n, x[300], y[300], c[41][41];

int Check(int l, int u, int r, int d) {
	for (int i=0;i<=40;++i)for(int j=0;j<=40;++j)c[i][j]=0;
	for (int i = 0; i < n; ++i) {
		++c[max(0, x[i]-u)][max(0, y[i]-l)];
		--c[max(0, x[i]-u)][min(40,y[i]+r+1)];
		--c[min(40,x[i]+d+1)][max(0, y[i]-l)];
		++c[min(40,x[i]+d+1)][min(40,y[i]+r+1)];
	}
	for(int i=0;i<=40;++i)for(int j=1;j<=40;++j)c[i][j]+=c[i][j-1];
	for(int i=1;i<=40;++i)for(int j=0;j<=40;++j)c[i][j]+=c[i-1][j];
	for(int i=0;i<R;++i)for(int j=0;j<C;++j)if(!c[i][j])return 0;
	return 1;
}

int main() {
	scanf("%d%d%d", &R, &C, &n);
	for (int i = 0; i < n; ++i) scanf("%d%d", x + i, y + i), --x[i], --y[i];

	for(int l=0;l<=40;++l)for(int r=0;r<=40-l;++r){
		for(int u=0;u<=40;++u){
			int lb=0,ub=39;
			while(lb<=ub){
				int md=lb+(ub-lb)/2;
				if(Check(l,u,r,md))ub=md-1,z=min(z,l+u+r+md);
				else lb=md+1;
			}
		}
	}
	printf("%d",z);
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%d%d", &R, &C, &n);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
cultivation.cpp:25:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for (int i = 0; i < n; ++i) scanf("%d%d", x + i, y + i), --x[i], --y[i];
      |                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 348 KB Output is correct
2 Correct 132 ms 344 KB Output is correct
3 Correct 126 ms 348 KB Output is correct
4 Correct 147 ms 396 KB Output is correct
5 Correct 124 ms 400 KB Output is correct
6 Correct 131 ms 348 KB Output is correct
7 Correct 128 ms 396 KB Output is correct
8 Correct 129 ms 400 KB Output is correct
9 Correct 126 ms 348 KB Output is correct
10 Correct 135 ms 348 KB Output is correct
11 Correct 126 ms 348 KB Output is correct
12 Correct 124 ms 348 KB Output is correct
13 Correct 155 ms 348 KB Output is correct
14 Correct 133 ms 400 KB Output is correct
15 Correct 129 ms 348 KB Output is correct
16 Correct 129 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 348 KB Output is correct
2 Correct 132 ms 344 KB Output is correct
3 Correct 126 ms 348 KB Output is correct
4 Correct 147 ms 396 KB Output is correct
5 Correct 124 ms 400 KB Output is correct
6 Correct 131 ms 348 KB Output is correct
7 Correct 128 ms 396 KB Output is correct
8 Correct 129 ms 400 KB Output is correct
9 Correct 126 ms 348 KB Output is correct
10 Correct 135 ms 348 KB Output is correct
11 Correct 126 ms 348 KB Output is correct
12 Correct 124 ms 348 KB Output is correct
13 Correct 155 ms 348 KB Output is correct
14 Correct 133 ms 400 KB Output is correct
15 Correct 129 ms 348 KB Output is correct
16 Correct 129 ms 344 KB Output is correct
17 Correct 150 ms 400 KB Output is correct
18 Correct 199 ms 404 KB Output is correct
19 Correct 204 ms 396 KB Output is correct
20 Correct 156 ms 348 KB Output is correct
21 Incorrect 229 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 348 KB Output is correct
2 Correct 132 ms 344 KB Output is correct
3 Correct 126 ms 348 KB Output is correct
4 Correct 147 ms 396 KB Output is correct
5 Correct 124 ms 400 KB Output is correct
6 Correct 131 ms 348 KB Output is correct
7 Correct 128 ms 396 KB Output is correct
8 Correct 129 ms 400 KB Output is correct
9 Correct 126 ms 348 KB Output is correct
10 Correct 135 ms 348 KB Output is correct
11 Correct 126 ms 348 KB Output is correct
12 Correct 124 ms 348 KB Output is correct
13 Correct 155 ms 348 KB Output is correct
14 Correct 133 ms 400 KB Output is correct
15 Correct 129 ms 348 KB Output is correct
16 Correct 129 ms 344 KB Output is correct
17 Correct 150 ms 400 KB Output is correct
18 Correct 199 ms 404 KB Output is correct
19 Correct 204 ms 396 KB Output is correct
20 Correct 156 ms 348 KB Output is correct
21 Incorrect 229 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 348 KB Output is correct
2 Correct 132 ms 344 KB Output is correct
3 Correct 126 ms 348 KB Output is correct
4 Correct 147 ms 396 KB Output is correct
5 Correct 124 ms 400 KB Output is correct
6 Correct 131 ms 348 KB Output is correct
7 Correct 128 ms 396 KB Output is correct
8 Correct 129 ms 400 KB Output is correct
9 Correct 126 ms 348 KB Output is correct
10 Correct 135 ms 348 KB Output is correct
11 Correct 126 ms 348 KB Output is correct
12 Correct 124 ms 348 KB Output is correct
13 Correct 155 ms 348 KB Output is correct
14 Correct 133 ms 400 KB Output is correct
15 Correct 129 ms 348 KB Output is correct
16 Correct 129 ms 344 KB Output is correct
17 Correct 150 ms 400 KB Output is correct
18 Correct 199 ms 404 KB Output is correct
19 Correct 204 ms 396 KB Output is correct
20 Correct 156 ms 348 KB Output is correct
21 Incorrect 229 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -