답안 #826729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826729 2023-08-16T00:31:53 Z jamezzz Cell Automaton (JOI23_cell) C++17
16 / 100
466 ms 127704 KB
#include <bits/stdc++.h>
using namespace std;

#define sf scanf
#define pf printf
typedef pair<int,int> ii;

const int m=4000;

int n,k;
int num[2*m+5];
int grid[m+5][m+5];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int main(){
	sf("%d%d",&n,&k);
	memset(grid,-1,sizeof grid);
	queue<ii> q;
	for(int i=0;i<n;++i){
		int x,y;sf("%d%d",&x,&y);
		x+=2000;y+=2000;
		grid[x][y]=0;
		q.push({x,y});
	}
	while(!q.empty()){
		auto[x,y]=q.front();q.pop();
		for(int i=0;i<4;++i){
			int nx=x+dx[i],ny=y+dy[i];
			if(nx<0||ny<0||nx>=m||ny>=m)continue;
			if(grid[nx][ny]!=-1)continue;
			grid[nx][ny]=grid[x][y]+1;
			q.push({nx,ny});
		}
	}
	for(int i=0;i<m;++i){
		for(int j=0;j<m;++j){
			++num[grid[i][j]];
		}
	}
	for(int i=0;i<k;++i){
		int x;sf("%d",&x);
		pf("%d\n",num[x]);
	}
}

Compilation message

cell.cpp: In function 'int main()':
cell.cpp:16:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  sf("%d%d",&n,&k);
      |    ^
cell.cpp:20:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   int x,y;sf("%d%d",&x,&y);
      |             ^
cell.cpp:41:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   int x;sf("%d",&x);
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 414 ms 63260 KB Output is correct
2 Correct 425 ms 63128 KB Output is correct
3 Correct 419 ms 63212 KB Output is correct
4 Correct 424 ms 63244 KB Output is correct
5 Correct 421 ms 63096 KB Output is correct
6 Correct 419 ms 63216 KB Output is correct
7 Correct 443 ms 63132 KB Output is correct
8 Correct 426 ms 63164 KB Output is correct
9 Correct 429 ms 63100 KB Output is correct
10 Correct 426 ms 63136 KB Output is correct
11 Correct 416 ms 63128 KB Output is correct
12 Correct 444 ms 63224 KB Output is correct
13 Correct 415 ms 63136 KB Output is correct
14 Correct 416 ms 63140 KB Output is correct
15 Correct 409 ms 63144 KB Output is correct
16 Correct 430 ms 63088 KB Output is correct
17 Correct 453 ms 63136 KB Output is correct
18 Correct 466 ms 63132 KB Output is correct
19 Correct 412 ms 63092 KB Output is correct
20 Correct 420 ms 63136 KB Output is correct
21 Correct 415 ms 63100 KB Output is correct
22 Correct 445 ms 63132 KB Output is correct
23 Correct 433 ms 63128 KB Output is correct
24 Correct 419 ms 63084 KB Output is correct
25 Correct 440 ms 63164 KB Output is correct
26 Correct 421 ms 63132 KB Output is correct
27 Correct 424 ms 63180 KB Output is correct
28 Correct 438 ms 63136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 414 ms 63260 KB Output is correct
2 Correct 425 ms 63128 KB Output is correct
3 Correct 419 ms 63212 KB Output is correct
4 Correct 424 ms 63244 KB Output is correct
5 Correct 421 ms 63096 KB Output is correct
6 Correct 419 ms 63216 KB Output is correct
7 Correct 443 ms 63132 KB Output is correct
8 Correct 426 ms 63164 KB Output is correct
9 Correct 429 ms 63100 KB Output is correct
10 Correct 426 ms 63136 KB Output is correct
11 Correct 416 ms 63128 KB Output is correct
12 Correct 444 ms 63224 KB Output is correct
13 Correct 415 ms 63136 KB Output is correct
14 Correct 416 ms 63140 KB Output is correct
15 Correct 409 ms 63144 KB Output is correct
16 Correct 430 ms 63088 KB Output is correct
17 Correct 453 ms 63136 KB Output is correct
18 Correct 466 ms 63132 KB Output is correct
19 Correct 412 ms 63092 KB Output is correct
20 Correct 420 ms 63136 KB Output is correct
21 Correct 415 ms 63100 KB Output is correct
22 Correct 445 ms 63132 KB Output is correct
23 Correct 433 ms 63128 KB Output is correct
24 Correct 419 ms 63084 KB Output is correct
25 Correct 440 ms 63164 KB Output is correct
26 Correct 421 ms 63132 KB Output is correct
27 Correct 424 ms 63180 KB Output is correct
28 Correct 438 ms 63136 KB Output is correct
29 Correct 461 ms 63132 KB Output is correct
30 Correct 428 ms 63252 KB Output is correct
31 Correct 431 ms 63104 KB Output is correct
32 Correct 452 ms 65828 KB Output is correct
33 Correct 405 ms 63104 KB Output is correct
34 Correct 440 ms 63228 KB Output is correct
35 Correct 416 ms 63124 KB Output is correct
36 Correct 419 ms 63128 KB Output is correct
37 Correct 432 ms 63256 KB Output is correct
38 Correct 425 ms 63388 KB Output is correct
39 Correct 421 ms 64216 KB Output is correct
40 Correct 455 ms 66208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 90 ms 127676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 90 ms 127676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 127704 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 94 ms 127704 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 414 ms 63260 KB Output is correct
2 Correct 425 ms 63128 KB Output is correct
3 Correct 419 ms 63212 KB Output is correct
4 Correct 424 ms 63244 KB Output is correct
5 Correct 421 ms 63096 KB Output is correct
6 Correct 419 ms 63216 KB Output is correct
7 Correct 443 ms 63132 KB Output is correct
8 Correct 426 ms 63164 KB Output is correct
9 Correct 429 ms 63100 KB Output is correct
10 Correct 426 ms 63136 KB Output is correct
11 Correct 416 ms 63128 KB Output is correct
12 Correct 444 ms 63224 KB Output is correct
13 Correct 415 ms 63136 KB Output is correct
14 Correct 416 ms 63140 KB Output is correct
15 Correct 409 ms 63144 KB Output is correct
16 Correct 430 ms 63088 KB Output is correct
17 Correct 453 ms 63136 KB Output is correct
18 Correct 466 ms 63132 KB Output is correct
19 Correct 412 ms 63092 KB Output is correct
20 Correct 420 ms 63136 KB Output is correct
21 Correct 415 ms 63100 KB Output is correct
22 Correct 445 ms 63132 KB Output is correct
23 Correct 433 ms 63128 KB Output is correct
24 Correct 419 ms 63084 KB Output is correct
25 Correct 440 ms 63164 KB Output is correct
26 Correct 421 ms 63132 KB Output is correct
27 Correct 424 ms 63180 KB Output is correct
28 Correct 438 ms 63136 KB Output is correct
29 Correct 461 ms 63132 KB Output is correct
30 Correct 428 ms 63252 KB Output is correct
31 Correct 431 ms 63104 KB Output is correct
32 Correct 452 ms 65828 KB Output is correct
33 Correct 405 ms 63104 KB Output is correct
34 Correct 440 ms 63228 KB Output is correct
35 Correct 416 ms 63124 KB Output is correct
36 Correct 419 ms 63128 KB Output is correct
37 Correct 432 ms 63256 KB Output is correct
38 Correct 425 ms 63388 KB Output is correct
39 Correct 421 ms 64216 KB Output is correct
40 Correct 455 ms 66208 KB Output is correct
41 Runtime error 90 ms 127676 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -