답안 #28607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28607 2017-07-16T07:57:25 Z Shocking Hot(#1200, khsoo01) Oriental P.A.D.A.K (FXCUP2_padak) C++14
0 / 1
716 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, m, k, b, z, x, y;
vector<int> d[1000005], arr;
queue<pair<int,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=1;i<=n;i++) {
		d[i].push_back(0);
		for(int j=1;j<=m;j++) d[i].push_back(inf);
	}
	for(int i=1;i<=k;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		if(d[A][B] == inf) {
			d[A][B] = 0;
			q.push({A, B});
		}
	}
	while(!q.empty()) {
		int A, B; tie(A, B) = q.front(); q.pop();
		arr.push_back(d[A][B]);
		for(int i=0;i<4;i++) {
			int na = A+dx[i], nb = B+dy[i];
			if(1 <= na && na <= n && 1 <= nb && nb <= m && d[na][nb] == inf) {
				d[na][nb] = d[A][B] + 1;
				q.push({na, nb});
			}
		}
	}
	for(auto &T : arr) {
		if(y/z < T) y++;
	}
	reverse(arr.begin(), arr.end());
	for(auto &T : arr) {
		if(x/z < T) x++;
	}
	printf("%d %d\n",x,y);
}

Compilation message

padak.cpp: In function 'int main()':
padak.cpp:13:36: 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:20:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 25460 KB Output is correct
2 Correct 6 ms 25460 KB Output is correct
3 Correct 43 ms 35712 KB Output is correct
4 Correct 66 ms 37612 KB Output is correct
5 Correct 49 ms 35708 KB Output is correct
6 Correct 59 ms 39500 KB Output is correct
7 Correct 53 ms 36572 KB Output is correct
8 Correct 46 ms 37832 KB Output is correct
9 Correct 139 ms 62940 KB Output is correct
10 Correct 49 ms 35720 KB Output is correct
11 Correct 56 ms 37656 KB Output is correct
12 Correct 53 ms 35712 KB Output is correct
13 Correct 79 ms 39516 KB Output is correct
14 Correct 43 ms 36588 KB Output is correct
15 Correct 56 ms 37836 KB Output is correct
16 Correct 216 ms 62940 KB Output is correct
17 Correct 109 ms 35984 KB Output is correct
18 Correct 93 ms 38296 KB Output is correct
19 Correct 59 ms 35896 KB Output is correct
20 Correct 89 ms 39628 KB Output is correct
21 Correct 83 ms 37628 KB Output is correct
22 Correct 53 ms 37848 KB Output is correct
23 Correct 279 ms 63004 KB Output is correct
24 Correct 503 ms 41016 KB Output is correct
25 Correct 523 ms 42916 KB Output is correct
26 Correct 443 ms 41116 KB Output is correct
27 Correct 716 ms 44812 KB Output is correct
28 Correct 483 ms 41884 KB Output is correct
29 Correct 309 ms 46032 KB Output is correct
30 Memory limit exceeded 676 ms 65536 KB Memory limit exceeded
31 Halted 0 ms 0 KB -