답안 #374191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374191 2021-03-06T21:10:24 Z Iwanttobreakfree Jakarta Skyscrapers (APIO15_skyscraper) C++17
22 / 100
10 ms 512 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	int N,M,pos,S,buscar,b;
	cin>>N>>M;
	queue <pair<int,int> >v;
	vector<pair<int,int> > doge(M);
	vector<int> distancia(N,1e9);
	for(int i=0;i<M;i++){
		cin>>pos>>S;
		if(i==0)b=pos;
		if(i==1)buscar=pos;
		doge[i]=make_pair(pos,S);
		if(pos==b)v.push(doge[i]);
	}
	queue <pair<pair<int,int>,int> > q;
	while(!v.empty()){
	q.push(make_pair(v.front(),0));
	v.pop();
}
	distancia[0]=0;
	while(!q.empty()){
		int p=q.front().first.first;
		int mov=q.front().first.second;
		int jump=q.front().second;
		q.pop();
		int po=p;
		int mo=mov;
		int jum=jump;
	while(p){
			p-=mov;
			jump++;
			if(p<0)break;
			if(distancia[p]>jump){
				distancia[p]=jump;
				//cout<<distancia[p]<<' '<<p<<' ';
				for(int i=0;i<M;i++)if(doge[i].first==p&&p!=buscar)q.push(make_pair(doge[i],jump));
			}
		}
	while(po<N){
		jum++;
		po+=mo;
		if(po>=N)break;
		if(distancia[po]>jum){
				distancia[po]=jum;
				//cout<<distancia[po]<<' '<<po<<' ';
				for(int i=0;i<M;i++)if(doge[i].first==po&&po!=buscar)q.push(make_pair(doge[i],jum));
			}
	}
}
if(distancia[buscar]==1e9)cout<<-1;
else cout<<distancia[buscar];
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:55:20: warning: 'buscar' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 | if(distancia[buscar]==1e9)cout<<-1;
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 4 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 9 ms 404 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 10 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Incorrect 3 ms 364 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 4 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 6 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 9 ms 364 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 4 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Incorrect 3 ms 364 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 4 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 6 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 10 ms 364 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Incorrect 4 ms 492 KB Output isn't correct
29 Halted 0 ms 0 KB -