답안 #68799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68799 2018-08-18T13:48:20 Z FedericoS Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 10784 KB
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
typedef pair<int,pair<int,int>> pp;

int N,M;
int B[30005],P[30005];
vector<int> V[30005];
deque<pp> Q;

int main(){

	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>B[i]>>P[i];
		if(i)
			V[B[i]].push_back(i);
	}

	//indice distanza posizione

	Q.push_back({0,{0,B[0]}});

	while(!Q.empty()){

		pp p=Q.front();
		Q.pop_front();

		//cout<<Q.size()<<" "<<p.first<<" "<<p.second.first<<" "<<p.second.second<<endl;

		if(p.first==1){
			cout<<p.second.first;
			return 0;
		}

		for(int x:V[p.second.second])
			Q.push_front({x,{p.second.first,B[x]}});
		V[p.second.second].clear();

		if(p.second.second==B[p.first]){
			if(p.second.second-P[p.first]>=0)
				Q.push_back({p.first,{p.second.first+1,p.second.second-P[p.first]}});
			if(p.second.second+P[p.first]<N)
				Q.push_back({p.first,{p.second.first+1,p.second.second+P[p.first]}});
		}

		if(p.second.second<B[p.first]){
			if(p.second.second-P[p.first]>=0)
				Q.push_back({p.first,{p.second.first+1,p.second.second-P[p.first]}});
		}

		if(p.second.second>B[p.first]){
			if(p.second.second+P[p.first]<N)
				Q.push_back({p.first,{p.second.first+1,p.second.second+P[p.first]}});
		}

	}

	cout<<-1;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1200 KB Output is correct
4 Correct 3 ms 1272 KB Output is correct
5 Correct 3 ms 1272 KB Output is correct
6 Correct 3 ms 1272 KB Output is correct
7 Correct 3 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1272 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 4 ms 1272 KB Output is correct
4 Correct 2 ms 1272 KB Output is correct
5 Correct 4 ms 1272 KB Output is correct
6 Correct 3 ms 1324 KB Output is correct
7 Correct 3 ms 1324 KB Output is correct
8 Correct 3 ms 1388 KB Output is correct
9 Correct 3 ms 1388 KB Output is correct
10 Correct 3 ms 1388 KB Output is correct
11 Correct 5 ms 1388 KB Output is correct
12 Correct 4 ms 1404 KB Output is correct
13 Correct 5 ms 1408 KB Output is correct
14 Correct 5 ms 1408 KB Output is correct
15 Correct 6 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1408 KB Output is correct
2 Correct 4 ms 1408 KB Output is correct
3 Correct 3 ms 1408 KB Output is correct
4 Correct 3 ms 1408 KB Output is correct
5 Correct 3 ms 1408 KB Output is correct
6 Correct 3 ms 1408 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 4 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 4 ms 1408 KB Output is correct
11 Correct 4 ms 1408 KB Output is correct
12 Correct 4 ms 1408 KB Output is correct
13 Correct 4 ms 1408 KB Output is correct
14 Correct 4 ms 1408 KB Output is correct
15 Correct 5 ms 1408 KB Output is correct
16 Correct 3 ms 1408 KB Output is correct
17 Correct 4 ms 1408 KB Output is correct
18 Correct 4 ms 1408 KB Output is correct
19 Correct 4 ms 1408 KB Output is correct
20 Correct 53 ms 1444 KB Output is correct
21 Correct 4 ms 1444 KB Output is correct
22 Correct 4 ms 1444 KB Output is correct
23 Correct 5 ms 1444 KB Output is correct
24 Correct 7 ms 1572 KB Output is correct
25 Correct 5 ms 1572 KB Output is correct
26 Correct 6 ms 1612 KB Output is correct
27 Correct 6 ms 1644 KB Output is correct
28 Correct 5 ms 1660 KB Output is correct
29 Correct 4 ms 1660 KB Output is correct
30 Correct 4 ms 1660 KB Output is correct
31 Correct 5 ms 1660 KB Output is correct
32 Correct 4 ms 1660 KB Output is correct
33 Correct 7 ms 1660 KB Output is correct
34 Correct 6 ms 1744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1744 KB Output is correct
2 Correct 3 ms 1744 KB Output is correct
3 Correct 3 ms 1744 KB Output is correct
4 Correct 3 ms 1744 KB Output is correct
5 Correct 4 ms 1744 KB Output is correct
6 Correct 3 ms 1744 KB Output is correct
7 Correct 3 ms 1744 KB Output is correct
8 Correct 4 ms 1744 KB Output is correct
9 Correct 3 ms 1744 KB Output is correct
10 Correct 3 ms 1744 KB Output is correct
11 Correct 4 ms 1752 KB Output is correct
12 Correct 5 ms 1780 KB Output is correct
13 Correct 4 ms 1780 KB Output is correct
14 Correct 4 ms 1780 KB Output is correct
15 Correct 4 ms 1780 KB Output is correct
16 Correct 3 ms 1780 KB Output is correct
17 Correct 4 ms 1780 KB Output is correct
18 Correct 4 ms 1780 KB Output is correct
19 Correct 4 ms 1780 KB Output is correct
20 Correct 49 ms 1804 KB Output is correct
21 Correct 5 ms 1804 KB Output is correct
22 Correct 4 ms 1804 KB Output is correct
23 Correct 4 ms 1804 KB Output is correct
24 Correct 5 ms 1804 KB Output is correct
25 Correct 4 ms 1888 KB Output is correct
26 Correct 5 ms 1888 KB Output is correct
27 Correct 5 ms 1888 KB Output is correct
28 Correct 6 ms 1888 KB Output is correct
29 Correct 5 ms 1888 KB Output is correct
30 Correct 5 ms 1888 KB Output is correct
31 Correct 5 ms 1888 KB Output is correct
32 Correct 5 ms 1888 KB Output is correct
33 Correct 6 ms 1888 KB Output is correct
34 Correct 7 ms 1940 KB Output is correct
35 Correct 27 ms 2720 KB Output is correct
36 Correct 7 ms 2720 KB Output is correct
37 Correct 18 ms 2852 KB Output is correct
38 Correct 25 ms 3140 KB Output is correct
39 Correct 32 ms 3276 KB Output is correct
40 Correct 25 ms 3540 KB Output is correct
41 Correct 23 ms 3804 KB Output is correct
42 Correct 18 ms 3940 KB Output is correct
43 Correct 23 ms 4788 KB Output is correct
44 Correct 66 ms 5124 KB Output is correct
45 Correct 33 ms 5124 KB Output is correct
46 Correct 23 ms 5160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5160 KB Output is correct
2 Correct 3 ms 5160 KB Output is correct
3 Correct 3 ms 5160 KB Output is correct
4 Correct 4 ms 5160 KB Output is correct
5 Correct 3 ms 5160 KB Output is correct
6 Correct 4 ms 5160 KB Output is correct
7 Correct 3 ms 5160 KB Output is correct
8 Correct 3 ms 5160 KB Output is correct
9 Correct 3 ms 5160 KB Output is correct
10 Correct 3 ms 5160 KB Output is correct
11 Correct 5 ms 5160 KB Output is correct
12 Correct 5 ms 5160 KB Output is correct
13 Correct 4 ms 5160 KB Output is correct
14 Correct 5 ms 5160 KB Output is correct
15 Correct 5 ms 5160 KB Output is correct
16 Correct 3 ms 5160 KB Output is correct
17 Correct 4 ms 5160 KB Output is correct
18 Correct 5 ms 5160 KB Output is correct
19 Correct 4 ms 5160 KB Output is correct
20 Correct 46 ms 5160 KB Output is correct
21 Correct 5 ms 5160 KB Output is correct
22 Correct 4 ms 5160 KB Output is correct
23 Correct 5 ms 5160 KB Output is correct
24 Correct 6 ms 5160 KB Output is correct
25 Correct 5 ms 5160 KB Output is correct
26 Correct 5 ms 5160 KB Output is correct
27 Correct 4 ms 5160 KB Output is correct
28 Correct 5 ms 5160 KB Output is correct
29 Correct 4 ms 5160 KB Output is correct
30 Correct 4 ms 5160 KB Output is correct
31 Correct 4 ms 5160 KB Output is correct
32 Correct 5 ms 5160 KB Output is correct
33 Correct 6 ms 5160 KB Output is correct
34 Correct 5 ms 5160 KB Output is correct
35 Correct 26 ms 5304 KB Output is correct
36 Correct 7 ms 5304 KB Output is correct
37 Correct 16 ms 5464 KB Output is correct
38 Correct 25 ms 5856 KB Output is correct
39 Correct 26 ms 5992 KB Output is correct
40 Correct 27 ms 6384 KB Output is correct
41 Correct 23 ms 6588 KB Output is correct
42 Correct 22 ms 6656 KB Output is correct
43 Correct 21 ms 7504 KB Output is correct
44 Correct 68 ms 7816 KB Output is correct
45 Correct 25 ms 7816 KB Output is correct
46 Correct 24 ms 7876 KB Output is correct
47 Correct 20 ms 8052 KB Output is correct
48 Correct 24 ms 8196 KB Output is correct
49 Correct 24 ms 8440 KB Output is correct
50 Correct 16 ms 8464 KB Output is correct
51 Correct 31 ms 9268 KB Output is correct
52 Correct 34 ms 9600 KB Output is correct
53 Correct 35 ms 9808 KB Output is correct
54 Correct 4 ms 9808 KB Output is correct
55 Correct 4 ms 9808 KB Output is correct
56 Execution timed out 1081 ms 10784 KB Time limit exceeded
57 Halted 0 ms 0 KB -