답안 #48170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48170 2018-05-10T12:28:49 Z WA_TLE Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 77372 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,bool>>que;
	que.pub(mt(stb,stp,0,true));
	que.pub(mt(stb,stp,0,false));
	used[stb].ins(stp);
	while(que.size()>0){
		int b,p,t;bool mu;tie(b,p,t,mu)=que.front();
		que.pof();
		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,true));que.puf(mt(b,it,t,false));}
			go[b].clear();
		}
		if(mu&&b+p<n&&used[b+p].count(p)==0){
			que.pub(mt(b+p,p,t+1,true));
			used[b+p].ins(p);
		}
		if((!mu)&&b-p>=0&&used[b-p].count(p)==0){
			que.pub(mt(b-p,p,t+1,false));
			used[b-p].ins(p);
		}
	}
	cout<<"-1"<<endl;
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:63:10: warning: 'stb' may be used uninitialized in this function [-Wmaybe-uninitialized]
  used[stb].ins(stp);
          ^
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 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 560 KB Output is correct
2 Correct 2 ms 560 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
4 Correct 2 ms 576 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 2 ms 584 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 3 ms 608 KB Output is correct
12 Correct 3 ms 636 KB Output is correct
13 Correct 3 ms 636 KB Output is correct
14 Correct 4 ms 892 KB Output is correct
15 Correct 3 ms 892 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 3 ms 892 KB Output is correct
14 Correct 4 ms 892 KB Output is correct
15 Correct 3 ms 892 KB Output is correct
16 Correct 2 ms 892 KB Output is correct
17 Correct 4 ms 892 KB Output is correct
18 Correct 3 ms 892 KB Output is correct
19 Correct 2 ms 892 KB Output is correct
20 Correct 4 ms 892 KB Output is correct
21 Correct 2 ms 892 KB Output is correct
22 Correct 2 ms 892 KB Output is correct
23 Correct 4 ms 896 KB Output is correct
24 Correct 5 ms 1020 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 4 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 10 ms 3324 KB Output is correct
32 Correct 8 ms 3324 KB Output is correct
33 Correct 35 ms 5884 KB Output is correct
34 Correct 20 ms 5884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5884 KB Output is correct
2 Correct 2 ms 5884 KB Output is correct
3 Correct 2 ms 5884 KB Output is correct
4 Correct 2 ms 5884 KB Output is correct
5 Correct 2 ms 5884 KB Output is correct
6 Correct 2 ms 5884 KB Output is correct
7 Correct 2 ms 5884 KB Output is correct
8 Correct 2 ms 5884 KB Output is correct
9 Correct 2 ms 5884 KB Output is correct
10 Correct 2 ms 5884 KB Output is correct
11 Correct 3 ms 5884 KB Output is correct
12 Correct 3 ms 5884 KB Output is correct
13 Correct 3 ms 5884 KB Output is correct
14 Correct 4 ms 5884 KB Output is correct
15 Correct 3 ms 5884 KB Output is correct
16 Correct 2 ms 5884 KB Output is correct
17 Correct 4 ms 5884 KB Output is correct
18 Correct 2 ms 5884 KB Output is correct
19 Correct 2 ms 5884 KB Output is correct
20 Correct 4 ms 5884 KB Output is correct
21 Correct 2 ms 5884 KB Output is correct
22 Correct 2 ms 5884 KB Output is correct
23 Correct 4 ms 5884 KB Output is correct
24 Correct 5 ms 5884 KB Output is correct
25 Correct 4 ms 5884 KB Output is correct
26 Correct 4 ms 5884 KB Output is correct
27 Correct 4 ms 5884 KB Output is correct
28 Correct 9 ms 5884 KB Output is correct
29 Correct 18 ms 5884 KB Output is correct
30 Correct 7 ms 5884 KB Output is correct
31 Correct 10 ms 5884 KB Output is correct
32 Correct 8 ms 5884 KB Output is correct
33 Correct 36 ms 5884 KB Output is correct
34 Correct 20 ms 5884 KB Output is correct
35 Correct 32 ms 5884 KB Output is correct
36 Correct 5 ms 5884 KB Output is correct
37 Correct 31 ms 5884 KB Output is correct
38 Correct 26 ms 5884 KB Output is correct
39 Correct 21 ms 5884 KB Output is correct
40 Correct 21 ms 5884 KB Output is correct
41 Correct 35 ms 5884 KB Output is correct
42 Correct 20 ms 5884 KB Output is correct
43 Correct 19 ms 5884 KB Output is correct
44 Correct 21 ms 5884 KB Output is correct
45 Correct 259 ms 21528 KB Output is correct
46 Correct 125 ms 21528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 21528 KB Output is correct
2 Correct 2 ms 21528 KB Output is correct
3 Correct 2 ms 21528 KB Output is correct
4 Correct 2 ms 21528 KB Output is correct
5 Correct 2 ms 21528 KB Output is correct
6 Correct 2 ms 21528 KB Output is correct
7 Correct 2 ms 21528 KB Output is correct
8 Correct 2 ms 21528 KB Output is correct
9 Correct 2 ms 21528 KB Output is correct
10 Correct 2 ms 21528 KB Output is correct
11 Correct 3 ms 21528 KB Output is correct
12 Correct 3 ms 21528 KB Output is correct
13 Correct 3 ms 21528 KB Output is correct
14 Correct 4 ms 21528 KB Output is correct
15 Correct 5 ms 21528 KB Output is correct
16 Correct 2 ms 21528 KB Output is correct
17 Correct 4 ms 21528 KB Output is correct
18 Correct 3 ms 21528 KB Output is correct
19 Correct 2 ms 21528 KB Output is correct
20 Correct 4 ms 21528 KB Output is correct
21 Correct 3 ms 21528 KB Output is correct
22 Correct 3 ms 21528 KB Output is correct
23 Correct 4 ms 21528 KB Output is correct
24 Correct 5 ms 21528 KB Output is correct
25 Correct 3 ms 21528 KB Output is correct
26 Correct 4 ms 21528 KB Output is correct
27 Correct 4 ms 21528 KB Output is correct
28 Correct 11 ms 21528 KB Output is correct
29 Correct 18 ms 21528 KB Output is correct
30 Correct 8 ms 21528 KB Output is correct
31 Correct 10 ms 21528 KB Output is correct
32 Correct 8 ms 21528 KB Output is correct
33 Correct 36 ms 21528 KB Output is correct
34 Correct 28 ms 21528 KB Output is correct
35 Correct 30 ms 21528 KB Output is correct
36 Correct 5 ms 21528 KB Output is correct
37 Correct 24 ms 21528 KB Output is correct
38 Correct 26 ms 21528 KB Output is correct
39 Correct 19 ms 21528 KB Output is correct
40 Correct 30 ms 21528 KB Output is correct
41 Correct 34 ms 21528 KB Output is correct
42 Correct 18 ms 21528 KB Output is correct
43 Correct 19 ms 21528 KB Output is correct
44 Correct 21 ms 21528 KB Output is correct
45 Correct 274 ms 21596 KB Output is correct
46 Correct 142 ms 21596 KB Output is correct
47 Correct 24 ms 21596 KB Output is correct
48 Correct 21 ms 21596 KB Output is correct
49 Correct 20 ms 21596 KB Output is correct
50 Correct 15 ms 21596 KB Output is correct
51 Correct 46 ms 21596 KB Output is correct
52 Correct 54 ms 21596 KB Output is correct
53 Correct 33 ms 21596 KB Output is correct
54 Correct 8 ms 21596 KB Output is correct
55 Correct 10 ms 21596 KB Output is correct
56 Correct 36 ms 21596 KB Output is correct
57 Correct 5 ms 21596 KB Output is correct
58 Correct 36 ms 21596 KB Output is correct
59 Correct 36 ms 21596 KB Output is correct
60 Correct 35 ms 21596 KB Output is correct
61 Correct 34 ms 21596 KB Output is correct
62 Correct 300 ms 26904 KB Output is correct
63 Execution timed out 1083 ms 77372 KB Time limit exceeded
64 Halted 0 ms 0 KB -