답안 #87780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
87780 2018-12-02T13:43:51 Z KCSC Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
625 ms 123452 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 30005;

int ans[DIM]; 
pair<int, int> arr[DIM];
vector<int> lst[DIM];
bitset<DIM> oki[DIM], vis;

struct str {
	int ps, pw, tm; };
deque<str> que;

int main(void) {
#ifdef HOME
	freopen("skyscraper.in", "r", stdin); 
	freopen("skyscraper.out", "w", stdout);
#endif
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> arr[i].first >> arr[i].second;
		lst[arr[i].first].push_back(i); ans[i] = 1000000000; }
	que.push_back({arr[0].first, arr[0].second, 0}); 
	ans[0] = 0; oki[arr[0].first][arr[0].second] = true;
	while (que.size()) {
		int ps = que.front().ps, pw = que.front().pw, tm = que.front().tm; 
		que.pop_front();
		if (!vis[ps]) {
			vis[ps] = true;
			for (int x : lst[ps]) {
				ans[x] = min(ans[x], tm);
				if (!oki[arr[x].first][arr[x].second]) {		
					oki[arr[x].first][arr[x].second] = true; 
					que.push_front({arr[x].first, arr[x].second, tm}); } } }
		if (ps + pw < n and !oki[ps + pw][pw]) {
			oki[ps + pw][pw] = true; 
			que.push_back({ps + pw, pw, tm + 1}); }
		if (ps - pw >= 0 and !oki[ps - pw][pw]) {
			oki[ps - pw][pw] = true; 
			que.push_back({ps - pw, pw, tm + 1}); } }
	if (ans[1] == 1000000000) {
		ans[1] = -1; }
	cout << ans[1];		 
	return 0; }	
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1204 KB Output is correct
4 Correct 3 ms 1204 KB Output is correct
5 Correct 3 ms 1348 KB Output is correct
6 Correct 3 ms 1448 KB Output is correct
7 Correct 3 ms 1688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1688 KB Output is correct
2 Correct 3 ms 1688 KB Output is correct
3 Correct 3 ms 1688 KB Output is correct
4 Correct 3 ms 1688 KB Output is correct
5 Correct 3 ms 1688 KB Output is correct
6 Correct 3 ms 1688 KB Output is correct
7 Correct 3 ms 1688 KB Output is correct
8 Correct 2 ms 1688 KB Output is correct
9 Correct 3 ms 1772 KB Output is correct
10 Correct 4 ms 1904 KB Output is correct
11 Correct 4 ms 1908 KB Output is correct
12 Correct 4 ms 1920 KB Output is correct
13 Correct 4 ms 1948 KB Output is correct
14 Correct 4 ms 2092 KB Output is correct
15 Correct 2 ms 2104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2104 KB Output is correct
2 Correct 3 ms 2104 KB Output is correct
3 Correct 3 ms 2104 KB Output is correct
4 Correct 4 ms 2104 KB Output is correct
5 Correct 3 ms 2104 KB Output is correct
6 Correct 3 ms 2104 KB Output is correct
7 Correct 4 ms 2104 KB Output is correct
8 Correct 3 ms 2104 KB Output is correct
9 Correct 4 ms 2104 KB Output is correct
10 Correct 4 ms 2104 KB Output is correct
11 Correct 5 ms 2168 KB Output is correct
12 Correct 5 ms 2168 KB Output is correct
13 Correct 4 ms 2168 KB Output is correct
14 Correct 5 ms 2220 KB Output is correct
15 Correct 5 ms 2220 KB Output is correct
16 Correct 4 ms 2220 KB Output is correct
17 Correct 10 ms 4516 KB Output is correct
18 Correct 4 ms 4516 KB Output is correct
19 Correct 4 ms 4516 KB Output is correct
20 Correct 14 ms 9332 KB Output is correct
21 Correct 4 ms 9332 KB Output is correct
22 Correct 3 ms 9332 KB Output is correct
23 Correct 12 ms 9332 KB Output is correct
24 Correct 15 ms 9332 KB Output is correct
25 Correct 16 ms 9332 KB Output is correct
26 Correct 15 ms 9332 KB Output is correct
27 Correct 15 ms 9332 KB Output is correct
28 Correct 16 ms 9332 KB Output is correct
29 Correct 16 ms 9344 KB Output is correct
30 Correct 14 ms 9344 KB Output is correct
31 Correct 14 ms 9356 KB Output is correct
32 Correct 16 ms 9360 KB Output is correct
33 Correct 16 ms 9364 KB Output is correct
34 Correct 18 ms 9376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9376 KB Output is correct
2 Correct 3 ms 9376 KB Output is correct
3 Correct 3 ms 9376 KB Output is correct
4 Correct 3 ms 9376 KB Output is correct
5 Correct 3 ms 9376 KB Output is correct
6 Correct 3 ms 9376 KB Output is correct
7 Correct 3 ms 9376 KB Output is correct
8 Correct 3 ms 9376 KB Output is correct
9 Correct 3 ms 9376 KB Output is correct
10 Correct 2 ms 9376 KB Output is correct
11 Correct 5 ms 9376 KB Output is correct
12 Correct 4 ms 9376 KB Output is correct
13 Correct 4 ms 9376 KB Output is correct
14 Correct 4 ms 9376 KB Output is correct
15 Correct 4 ms 9376 KB Output is correct
16 Correct 3 ms 9376 KB Output is correct
17 Correct 10 ms 9376 KB Output is correct
18 Correct 3 ms 9376 KB Output is correct
19 Correct 3 ms 9376 KB Output is correct
20 Correct 9 ms 9524 KB Output is correct
21 Correct 4 ms 9524 KB Output is correct
22 Correct 3 ms 9524 KB Output is correct
23 Correct 11 ms 9524 KB Output is correct
24 Correct 15 ms 9524 KB Output is correct
25 Correct 15 ms 9588 KB Output is correct
26 Correct 14 ms 9608 KB Output is correct
27 Correct 15 ms 9624 KB Output is correct
28 Correct 16 ms 9640 KB Output is correct
29 Correct 14 ms 9660 KB Output is correct
30 Correct 14 ms 9660 KB Output is correct
31 Correct 14 ms 9660 KB Output is correct
32 Correct 14 ms 9664 KB Output is correct
33 Correct 17 ms 9680 KB Output is correct
34 Correct 17 ms 9692 KB Output is correct
35 Correct 29 ms 9692 KB Output is correct
36 Correct 12 ms 9692 KB Output is correct
37 Correct 30 ms 10476 KB Output is correct
38 Correct 37 ms 11148 KB Output is correct
39 Correct 39 ms 11412 KB Output is correct
40 Correct 38 ms 11788 KB Output is correct
41 Correct 40 ms 12040 KB Output is correct
42 Correct 30 ms 12040 KB Output is correct
43 Correct 30 ms 12116 KB Output is correct
44 Correct 31 ms 12300 KB Output is correct
45 Correct 40 ms 12832 KB Output is correct
46 Correct 40 ms 13040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 13040 KB Output is correct
2 Correct 3 ms 13040 KB Output is correct
3 Correct 3 ms 13040 KB Output is correct
4 Correct 3 ms 13040 KB Output is correct
5 Correct 3 ms 13040 KB Output is correct
6 Correct 3 ms 13040 KB Output is correct
7 Correct 3 ms 13040 KB Output is correct
8 Correct 3 ms 13040 KB Output is correct
9 Correct 3 ms 13040 KB Output is correct
10 Correct 4 ms 13040 KB Output is correct
11 Correct 5 ms 13040 KB Output is correct
12 Correct 5 ms 13040 KB Output is correct
13 Correct 5 ms 13040 KB Output is correct
14 Correct 5 ms 13040 KB Output is correct
15 Correct 5 ms 13040 KB Output is correct
16 Correct 4 ms 13040 KB Output is correct
17 Correct 9 ms 13040 KB Output is correct
18 Correct 4 ms 13040 KB Output is correct
19 Correct 4 ms 13040 KB Output is correct
20 Correct 17 ms 13040 KB Output is correct
21 Correct 4 ms 13040 KB Output is correct
22 Correct 4 ms 13040 KB Output is correct
23 Correct 13 ms 13040 KB Output is correct
24 Correct 16 ms 13040 KB Output is correct
25 Correct 17 ms 13040 KB Output is correct
26 Correct 17 ms 13040 KB Output is correct
27 Correct 16 ms 13040 KB Output is correct
28 Correct 18 ms 13040 KB Output is correct
29 Correct 14 ms 13040 KB Output is correct
30 Correct 14 ms 13040 KB Output is correct
31 Correct 15 ms 13040 KB Output is correct
32 Correct 12 ms 13040 KB Output is correct
33 Correct 17 ms 13040 KB Output is correct
34 Correct 17 ms 13040 KB Output is correct
35 Correct 29 ms 13040 KB Output is correct
36 Correct 12 ms 13040 KB Output is correct
37 Correct 30 ms 13420 KB Output is correct
38 Correct 38 ms 14216 KB Output is correct
39 Correct 37 ms 14368 KB Output is correct
40 Correct 37 ms 14760 KB Output is correct
41 Correct 37 ms 14912 KB Output is correct
42 Correct 29 ms 14912 KB Output is correct
43 Correct 29 ms 15052 KB Output is correct
44 Correct 30 ms 15236 KB Output is correct
45 Correct 41 ms 15928 KB Output is correct
46 Correct 39 ms 16012 KB Output is correct
47 Correct 142 ms 54392 KB Output is correct
48 Correct 22 ms 54392 KB Output is correct
49 Correct 21 ms 54392 KB Output is correct
50 Correct 15 ms 54392 KB Output is correct
51 Correct 224 ms 120252 KB Output is correct
52 Correct 215 ms 120488 KB Output is correct
53 Correct 209 ms 120836 KB Output is correct
54 Correct 96 ms 120836 KB Output is correct
55 Correct 122 ms 120836 KB Output is correct
56 Correct 195 ms 121324 KB Output is correct
57 Correct 210 ms 121324 KB Output is correct
58 Correct 188 ms 121324 KB Output is correct
59 Correct 212 ms 121324 KB Output is correct
60 Correct 211 ms 121324 KB Output is correct
61 Correct 210 ms 121604 KB Output is correct
62 Correct 304 ms 122520 KB Output is correct
63 Correct 385 ms 122520 KB Output is correct
64 Correct 358 ms 122532 KB Output is correct
65 Correct 452 ms 122888 KB Output is correct
66 Correct 582 ms 123168 KB Output is correct
67 Correct 625 ms 123452 KB Output is correct