답안 #74348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74348 2018-08-31T10:57:03 Z khsoo01 Oriental P.A.D.A.K (FXCUP2_padak) C++11
1 / 1
327 ms 8776 KB
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, m, k, b, z, x, y, a[1000005], d[1000005];
queue<int> q;
 
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
int main()
{
	scanf("%d%d%d%d%d",&n,&m,&k,&b,&z);
	for(int i=0;i<n*m;i++) d[i] = inf;
	for(int i=1;i<=k;i++) {
		int A, B;
		scanf("%d%d",&A,&B); A--; B--;
		if(d[A*m+B] == inf) {
			d[A*m+B] = 0;
			q.push(A*m+B);
		}
	}
	while(!q.empty()) {
		int T = q.front(); q.pop();
		int A = T/m, B = T%m;
		if(y/z < d[T]) y++;
		a[d[T]]++;
		for(int i=0;i<4;i++) {
			int na = A+dx[i], nb = B+dy[i];
			if(0 <= na && na < n && 0 <= nb && nb < m && d[na*m+nb] == inf) {
				d[na*m+nb] = d[T] + 1;
				q.push(na*m+nb);
			}
		}
	}
	for(int i=n*m;i>=0;i--) {
		for(int j=0;j<a[i];j++) {
			if(x/z < i) x++;
		}
	}
	printf("%d %d\n",x,y);
}

Compilation message

padak.cpp: In function 'int main()':
padak.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d%d",&n,&m,&k,&b,&z);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
padak.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B); A--; B--;
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
3 Correct 125 ms 4392 KB Output is correct
4 Correct 37 ms 4392 KB Output is correct
5 Correct 41 ms 4480 KB Output is correct
6 Correct 38 ms 4620 KB Output is correct
7 Correct 37 ms 4620 KB Output is correct
8 Correct 33 ms 7868 KB Output is correct
9 Correct 33 ms 7868 KB Output is correct
10 Correct 40 ms 7868 KB Output is correct
11 Correct 41 ms 7868 KB Output is correct
12 Correct 38 ms 7868 KB Output is correct
13 Correct 36 ms 7868 KB Output is correct
14 Correct 39 ms 7868 KB Output is correct
15 Correct 33 ms 7868 KB Output is correct
16 Correct 35 ms 7868 KB Output is correct
17 Correct 43 ms 7868 KB Output is correct
18 Correct 47 ms 7868 KB Output is correct
19 Correct 58 ms 7868 KB Output is correct
20 Correct 40 ms 7868 KB Output is correct
21 Correct 50 ms 7868 KB Output is correct
22 Correct 38 ms 7868 KB Output is correct
23 Correct 44 ms 7868 KB Output is correct
24 Correct 306 ms 8572 KB Output is correct
25 Correct 313 ms 8776 KB Output is correct
26 Correct 310 ms 8776 KB Output is correct
27 Correct 327 ms 8776 KB Output is correct
28 Correct 323 ms 8776 KB Output is correct
29 Correct 302 ms 8776 KB Output is correct
30 Correct 315 ms 8776 KB Output is correct
31 Correct 33 ms 8776 KB Output is correct
32 Correct 34 ms 8776 KB Output is correct