답안 #48025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48025 2018-05-09T12:11:43 Z WA_TLE Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 49564 KB
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=4.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//0-1 dfs
	int n,m,i;cin>>n>>m;
	vector<vector<int>>go(n);
	int stb,stp,enb;
	for(i=0;i<m;i++){
		int b,p;cin>>b>>p;
		if(i==0){stb=b;stp=p;}
		if(i==1){enb=b;}
		go[b].pub(p);
	}
	set<pair<int,int>>used;
	deque<tuple<int,int,int>>que;
	que.pub(mt(stb,stp,0));
	while(que.size()>0){
		int b,p,t;tie(b,p,t)=que.front();
		que.pof();
		if(b<0||b>=n){continue;}
		if(used.count(mp(b,p))>0){continue;}
		if(b==enb){cout<<t<<endl;return 0;}
		//cerr<<"de"<<b<<" "<<p<<" "<<t<<endl;
		used.ins(mp(b,p));
		if(go[b].size()>0){
			for(auto it:go[b]){que.puf(mt(b,it,t));}
			go[b].clear();
		}
		que.pub(mt(b+p,p,t+1));
		que.pub(mt(b-p,p,t+1));
	}
	cout<<"-1"<<endl;
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:67:3: warning: 'enb' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(b==enb){cout<<t<<endl;return 0;}
   ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 2 ms 660 KB Output is correct
5 Correct 3 ms 660 KB Output is correct
6 Correct 2 ms 756 KB Output is correct
7 Correct 2 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 756 KB Output is correct
2 Correct 2 ms 864 KB Output is correct
3 Correct 2 ms 872 KB Output is correct
4 Correct 2 ms 892 KB Output is correct
5 Correct 2 ms 892 KB Output is correct
6 Correct 2 ms 892 KB Output is correct
7 Correct 2 ms 892 KB Output is correct
8 Correct 2 ms 892 KB Output is correct
9 Correct 2 ms 892 KB Output is correct
10 Correct 2 ms 1052 KB Output is correct
11 Correct 3 ms 1052 KB Output is correct
12 Correct 3 ms 1052 KB Output is correct
13 Correct 3 ms 1052 KB Output is correct
14 Correct 5 ms 1240 KB Output is correct
15 Correct 3 ms 1240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1240 KB Output is correct
2 Correct 2 ms 1240 KB Output is correct
3 Correct 2 ms 1240 KB Output is correct
4 Correct 2 ms 1240 KB Output is correct
5 Correct 2 ms 1240 KB Output is correct
6 Correct 2 ms 1240 KB Output is correct
7 Correct 2 ms 1240 KB Output is correct
8 Correct 2 ms 1240 KB Output is correct
9 Correct 2 ms 1240 KB Output is correct
10 Correct 2 ms 1240 KB Output is correct
11 Correct 3 ms 1240 KB Output is correct
12 Correct 3 ms 1240 KB Output is correct
13 Correct 3 ms 1240 KB Output is correct
14 Correct 5 ms 1372 KB Output is correct
15 Correct 3 ms 1372 KB Output is correct
16 Correct 2 ms 1372 KB Output is correct
17 Correct 4 ms 1372 KB Output is correct
18 Correct 3 ms 1372 KB Output is correct
19 Correct 2 ms 1372 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 3 ms 1372 KB Output is correct
22 Correct 2 ms 1372 KB Output is correct
23 Correct 4 ms 1496 KB Output is correct
24 Correct 6 ms 1636 KB Output is correct
25 Correct 3 ms 1636 KB Output is correct
26 Correct 4 ms 1636 KB Output is correct
27 Correct 4 ms 1636 KB Output is correct
28 Correct 13 ms 2348 KB Output is correct
29 Correct 45 ms 4288 KB Output is correct
30 Correct 10 ms 4288 KB Output is correct
31 Correct 22 ms 4288 KB Output is correct
32 Correct 15 ms 4288 KB Output is correct
33 Correct 106 ms 7252 KB Output is correct
34 Correct 49 ms 7252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7252 KB Output is correct
2 Correct 2 ms 7252 KB Output is correct
3 Correct 2 ms 7252 KB Output is correct
4 Correct 2 ms 7252 KB Output is correct
5 Correct 2 ms 7252 KB Output is correct
6 Correct 2 ms 7252 KB Output is correct
7 Correct 2 ms 7252 KB Output is correct
8 Correct 2 ms 7252 KB Output is correct
9 Correct 2 ms 7252 KB Output is correct
10 Correct 2 ms 7252 KB Output is correct
11 Correct 3 ms 7252 KB Output is correct
12 Correct 3 ms 7252 KB Output is correct
13 Correct 3 ms 7252 KB Output is correct
14 Correct 5 ms 7252 KB Output is correct
15 Correct 3 ms 7252 KB Output is correct
16 Correct 2 ms 7252 KB Output is correct
17 Correct 4 ms 7252 KB Output is correct
18 Correct 2 ms 7252 KB Output is correct
19 Correct 2 ms 7252 KB Output is correct
20 Correct 4 ms 7252 KB Output is correct
21 Correct 2 ms 7252 KB Output is correct
22 Correct 2 ms 7252 KB Output is correct
23 Correct 4 ms 7252 KB Output is correct
24 Correct 6 ms 7252 KB Output is correct
25 Correct 3 ms 7252 KB Output is correct
26 Correct 4 ms 7252 KB Output is correct
27 Correct 4 ms 7252 KB Output is correct
28 Correct 13 ms 7252 KB Output is correct
29 Correct 44 ms 7252 KB Output is correct
30 Correct 11 ms 7252 KB Output is correct
31 Correct 21 ms 7252 KB Output is correct
32 Correct 14 ms 7252 KB Output is correct
33 Correct 109 ms 7488 KB Output is correct
34 Correct 50 ms 7488 KB Output is correct
35 Correct 31 ms 7488 KB Output is correct
36 Correct 5 ms 7488 KB Output is correct
37 Correct 18 ms 7488 KB Output is correct
38 Correct 24 ms 7488 KB Output is correct
39 Correct 19 ms 7488 KB Output is correct
40 Correct 21 ms 7488 KB Output is correct
41 Correct 21 ms 7488 KB Output is correct
42 Correct 18 ms 7488 KB Output is correct
43 Correct 19 ms 7488 KB Output is correct
44 Correct 19 ms 7488 KB Output is correct
45 Correct 636 ms 27536 KB Output is correct
46 Correct 245 ms 27536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 27536 KB Output is correct
2 Correct 2 ms 27536 KB Output is correct
3 Correct 2 ms 27536 KB Output is correct
4 Correct 2 ms 27536 KB Output is correct
5 Correct 2 ms 27536 KB Output is correct
6 Correct 2 ms 27536 KB Output is correct
7 Correct 2 ms 27536 KB Output is correct
8 Correct 2 ms 27536 KB Output is correct
9 Correct 2 ms 27536 KB Output is correct
10 Correct 2 ms 27536 KB Output is correct
11 Correct 3 ms 27536 KB Output is correct
12 Correct 3 ms 27536 KB Output is correct
13 Correct 3 ms 27536 KB Output is correct
14 Correct 5 ms 27536 KB Output is correct
15 Correct 3 ms 27536 KB Output is correct
16 Correct 2 ms 27536 KB Output is correct
17 Correct 4 ms 27536 KB Output is correct
18 Correct 3 ms 27536 KB Output is correct
19 Correct 2 ms 27536 KB Output is correct
20 Correct 4 ms 27536 KB Output is correct
21 Correct 3 ms 27536 KB Output is correct
22 Correct 2 ms 27536 KB Output is correct
23 Correct 5 ms 27536 KB Output is correct
24 Correct 7 ms 27536 KB Output is correct
25 Correct 4 ms 27536 KB Output is correct
26 Correct 4 ms 27536 KB Output is correct
27 Correct 4 ms 27536 KB Output is correct
28 Correct 14 ms 27536 KB Output is correct
29 Correct 43 ms 27536 KB Output is correct
30 Correct 10 ms 27536 KB Output is correct
31 Correct 20 ms 27536 KB Output is correct
32 Correct 15 ms 27536 KB Output is correct
33 Correct 108 ms 27536 KB Output is correct
34 Correct 48 ms 27536 KB Output is correct
35 Correct 33 ms 27536 KB Output is correct
36 Correct 5 ms 27536 KB Output is correct
37 Correct 20 ms 27536 KB Output is correct
38 Correct 26 ms 27536 KB Output is correct
39 Correct 19 ms 27536 KB Output is correct
40 Correct 25 ms 27536 KB Output is correct
41 Correct 21 ms 27536 KB Output is correct
42 Correct 18 ms 27536 KB Output is correct
43 Correct 20 ms 27536 KB Output is correct
44 Correct 18 ms 27536 KB Output is correct
45 Correct 675 ms 30688 KB Output is correct
46 Correct 241 ms 30688 KB Output is correct
47 Correct 23 ms 30688 KB Output is correct
48 Correct 20 ms 30688 KB Output is correct
49 Correct 19 ms 30688 KB Output is correct
50 Correct 14 ms 30688 KB Output is correct
51 Correct 61 ms 30688 KB Output is correct
52 Correct 70 ms 30688 KB Output is correct
53 Correct 35 ms 30688 KB Output is correct
54 Correct 6 ms 30688 KB Output is correct
55 Correct 10 ms 30688 KB Output is correct
56 Correct 31 ms 30688 KB Output is correct
57 Correct 4 ms 30688 KB Output is correct
58 Correct 38 ms 30688 KB Output is correct
59 Correct 43 ms 30688 KB Output is correct
60 Correct 41 ms 30688 KB Output is correct
61 Correct 40 ms 30688 KB Output is correct
62 Correct 515 ms 33824 KB Output is correct
63 Execution timed out 1083 ms 49564 KB Time limit exceeded
64 Halted 0 ms 0 KB -