Submission #48031

# Submission time Handle Problem Language Result Execution time Memory
48031 2018-05-09T12:25:50 Z WA_TLE Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 63836 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);
	}
	vector<unordered_set<int>>used(n);
	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[b].count(p)>0){continue;}
		if(b==enb){cout<<t<<endl;return 0;}
		//cerr<<"de"<<b<<" "<<p<<" "<<t<<endl;
		used[b].ins(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;}
   ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 536 KB Output is correct
2 Correct 2 ms 572 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 2 ms 572 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Correct 3 ms 636 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 4 ms 892 KB Output is correct
15 Correct 3 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 892 KB Output is correct
2 Correct 2 ms 892 KB Output is correct
3 Correct 2 ms 892 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 892 KB Output is correct
11 Correct 3 ms 892 KB Output is correct
12 Correct 3 ms 892 KB Output is correct
13 Correct 2 ms 892 KB Output is correct
14 Correct 4 ms 980 KB Output is correct
15 Correct 3 ms 980 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 3 ms 980 KB Output is correct
18 Correct 2 ms 980 KB Output is correct
19 Correct 2 ms 980 KB Output is correct
20 Correct 3 ms 980 KB Output is correct
21 Correct 2 ms 980 KB Output is correct
22 Correct 2 ms 980 KB Output is correct
23 Correct 4 ms 980 KB Output is correct
24 Correct 5 ms 1020 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 3 ms 1020 KB Output is correct
27 Correct 4 ms 1020 KB Output is correct
28 Correct 9 ms 1660 KB Output is correct
29 Correct 18 ms 3324 KB Output is correct
30 Correct 6 ms 3324 KB Output is correct
31 Correct 11 ms 3324 KB Output is correct
32 Correct 8 ms 3324 KB Output is correct
33 Correct 37 ms 5756 KB Output is correct
34 Correct 20 ms 5756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5756 KB Output is correct
2 Correct 2 ms 5756 KB Output is correct
3 Correct 2 ms 5756 KB Output is correct
4 Correct 2 ms 5756 KB Output is correct
5 Correct 2 ms 5756 KB Output is correct
6 Correct 2 ms 5756 KB Output is correct
7 Correct 2 ms 5756 KB Output is correct
8 Correct 2 ms 5756 KB Output is correct
9 Correct 2 ms 5756 KB Output is correct
10 Correct 2 ms 5756 KB Output is correct
11 Correct 3 ms 5756 KB Output is correct
12 Correct 3 ms 5756 KB Output is correct
13 Correct 2 ms 5756 KB Output is correct
14 Correct 4 ms 5756 KB Output is correct
15 Correct 3 ms 5756 KB Output is correct
16 Correct 2 ms 5756 KB Output is correct
17 Correct 3 ms 5756 KB Output is correct
18 Correct 2 ms 5756 KB Output is correct
19 Correct 2 ms 5756 KB Output is correct
20 Correct 3 ms 5756 KB Output is correct
21 Correct 2 ms 5756 KB Output is correct
22 Correct 2 ms 5756 KB Output is correct
23 Correct 4 ms 5756 KB Output is correct
24 Correct 5 ms 5756 KB Output is correct
25 Correct 3 ms 5756 KB Output is correct
26 Correct 4 ms 5756 KB Output is correct
27 Correct 4 ms 5756 KB Output is correct
28 Correct 9 ms 5756 KB Output is correct
29 Correct 19 ms 5756 KB Output is correct
30 Correct 6 ms 5756 KB Output is correct
31 Correct 10 ms 5756 KB Output is correct
32 Correct 8 ms 5756 KB Output is correct
33 Correct 37 ms 5816 KB Output is correct
34 Correct 20 ms 5816 KB Output is correct
35 Correct 30 ms 5816 KB Output is correct
36 Correct 5 ms 5816 KB Output is correct
37 Correct 16 ms 5816 KB Output is correct
38 Correct 22 ms 5816 KB Output is correct
39 Correct 20 ms 5816 KB Output is correct
40 Correct 20 ms 5816 KB Output is correct
41 Correct 20 ms 5816 KB Output is correct
42 Correct 18 ms 5816 KB Output is correct
43 Correct 18 ms 5816 KB Output is correct
44 Correct 18 ms 5816 KB Output is correct
45 Correct 247 ms 21372 KB Output is correct
46 Correct 111 ms 21372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 21372 KB Output is correct
2 Correct 2 ms 21372 KB Output is correct
3 Correct 2 ms 21372 KB Output is correct
4 Correct 2 ms 21372 KB Output is correct
5 Correct 2 ms 21372 KB Output is correct
6 Correct 2 ms 21372 KB Output is correct
7 Correct 2 ms 21372 KB Output is correct
8 Correct 2 ms 21372 KB Output is correct
9 Correct 2 ms 21372 KB Output is correct
10 Correct 2 ms 21372 KB Output is correct
11 Correct 3 ms 21372 KB Output is correct
12 Correct 2 ms 21372 KB Output is correct
13 Correct 3 ms 21372 KB Output is correct
14 Correct 4 ms 21372 KB Output is correct
15 Correct 3 ms 21372 KB Output is correct
16 Correct 2 ms 21372 KB Output is correct
17 Correct 3 ms 21372 KB Output is correct
18 Correct 2 ms 21372 KB Output is correct
19 Correct 2 ms 21372 KB Output is correct
20 Correct 3 ms 21372 KB Output is correct
21 Correct 2 ms 21372 KB Output is correct
22 Correct 2 ms 21372 KB Output is correct
23 Correct 3 ms 21372 KB Output is correct
24 Correct 5 ms 21372 KB Output is correct
25 Correct 3 ms 21372 KB Output is correct
26 Correct 4 ms 21372 KB Output is correct
27 Correct 4 ms 21372 KB Output is correct
28 Correct 8 ms 21372 KB Output is correct
29 Correct 17 ms 21372 KB Output is correct
30 Correct 6 ms 21372 KB Output is correct
31 Correct 11 ms 21372 KB Output is correct
32 Correct 8 ms 21372 KB Output is correct
33 Correct 40 ms 21372 KB Output is correct
34 Correct 21 ms 21372 KB Output is correct
35 Correct 24 ms 21372 KB Output is correct
36 Correct 5 ms 21372 KB Output is correct
37 Correct 16 ms 21372 KB Output is correct
38 Correct 22 ms 21372 KB Output is correct
39 Correct 19 ms 21372 KB Output is correct
40 Correct 20 ms 21372 KB Output is correct
41 Correct 20 ms 21372 KB Output is correct
42 Correct 18 ms 21372 KB Output is correct
43 Correct 18 ms 21372 KB Output is correct
44 Correct 18 ms 21372 KB Output is correct
45 Correct 235 ms 21460 KB Output is correct
46 Correct 110 ms 21460 KB Output is correct
47 Correct 20 ms 21460 KB Output is correct
48 Correct 21 ms 21460 KB Output is correct
49 Correct 19 ms 21460 KB Output is correct
50 Correct 15 ms 21460 KB Output is correct
51 Correct 43 ms 21460 KB Output is correct
52 Correct 49 ms 21460 KB Output is correct
53 Correct 30 ms 21460 KB Output is correct
54 Correct 7 ms 21460 KB Output is correct
55 Correct 9 ms 21460 KB Output is correct
56 Correct 31 ms 21460 KB Output is correct
57 Correct 5 ms 21460 KB Output is correct
58 Correct 31 ms 21460 KB Output is correct
59 Correct 33 ms 21460 KB Output is correct
60 Correct 31 ms 21460 KB Output is correct
61 Correct 33 ms 21460 KB Output is correct
62 Correct 306 ms 23804 KB Output is correct
63 Execution timed out 1088 ms 63836 KB Time limit exceeded
64 Halted 0 ms 0 KB -