Submission #1028553

# Submission time Handle Problem Language Result Execution time Memory
1028553 2024-07-20T04:21:06 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 63928 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=3e4+5;
int const inf=1e9+7;

set<int> sky[N];
int pw[N];
int pos[N];
set<pair<int,int>> vis;

int main(){
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i){
		cin>>pos[i]>>pw[i];
		sky[pos[i]].insert(pw[i]);
	}
	int tar=pos[1];
	set<int> in;
	in.insert(pos[0]);
	vis.insert({pos[0],pw[0]});
	int cur=0;
	while(in.size()){
		vector<pair<int,int>> upd;
		for(int c:in){
			// cout<<"sky := "<<c<<endl;
			if(c==tar){
				cout<<cur<<endl;
				return 0;
			}
			for(int p:sky[c]){
				// cout<<p<<' ';
				if(c+p<n)
					upd.push_back({c+p,p});
				if(c-p>=0)
					upd.push_back({c-p,p});
			}
			// cout<<endl;
			sky[c].clear();
		}
		in.clear();
		// cout<<"Upd"<<endl;
		for(auto [s,p]:upd){

			if(vis.find({s,p})!=vis.end())
				continue;
			// cout<<s<<' '<<p<<endl;
			vis.insert({s,p});
			sky[s].insert(p);
			in.insert(s);
		}
		cur++;
		// cout<<"next"<<endl;
	}
	cout<<-1<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1624 KB Output is correct
2 Correct 1 ms 1624 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 3 ms 2140 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 3 ms 2260 KB Output is correct
15 Correct 4 ms 1880 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 1 ms 1884 KB Output is correct
19 Correct 1 ms 1884 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 1 ms 1884 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 3 ms 2112 KB Output is correct
25 Correct 1 ms 1884 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 2 ms 1884 KB Output is correct
28 Correct 9 ms 2708 KB Output is correct
29 Correct 30 ms 4552 KB Output is correct
30 Correct 6 ms 2396 KB Output is correct
31 Correct 13 ms 3160 KB Output is correct
32 Correct 9 ms 2908 KB Output is correct
33 Correct 57 ms 7408 KB Output is correct
34 Correct 26 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1628 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1624 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1628 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 3 ms 2140 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 2 ms 2116 KB Output is correct
18 Correct 1 ms 1884 KB Output is correct
19 Correct 1 ms 1884 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 1 ms 1884 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 3 ms 1884 KB Output is correct
24 Correct 4 ms 2140 KB Output is correct
25 Correct 2 ms 1880 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 3 ms 1884 KB Output is correct
28 Correct 9 ms 2652 KB Output is correct
29 Correct 28 ms 4544 KB Output is correct
30 Correct 7 ms 2396 KB Output is correct
31 Correct 15 ms 3336 KB Output is correct
32 Correct 11 ms 2904 KB Output is correct
33 Correct 67 ms 7336 KB Output is correct
34 Correct 29 ms 4948 KB Output is correct
35 Correct 19 ms 3928 KB Output is correct
36 Correct 2 ms 2140 KB Output is correct
37 Correct 10 ms 3420 KB Output is correct
38 Correct 16 ms 3676 KB Output is correct
39 Correct 12 ms 3672 KB Output is correct
40 Correct 14 ms 3420 KB Output is correct
41 Correct 14 ms 3672 KB Output is correct
42 Correct 8 ms 2140 KB Output is correct
43 Correct 9 ms 2140 KB Output is correct
44 Correct 7 ms 1956 KB Output is correct
45 Correct 313 ms 24464 KB Output is correct
46 Correct 144 ms 16680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 1 ms 1628 KB Output is correct
3 Correct 1 ms 1628 KB Output is correct
4 Correct 1 ms 1628 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1624 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1624 KB Output is correct
10 Correct 2 ms 1724 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 4 ms 2140 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 1 ms 1884 KB Output is correct
17 Correct 2 ms 1884 KB Output is correct
18 Correct 1 ms 1884 KB Output is correct
19 Correct 1 ms 1884 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 1 ms 1884 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 3 ms 1884 KB Output is correct
24 Correct 4 ms 2392 KB Output is correct
25 Correct 2 ms 1880 KB Output is correct
26 Correct 2 ms 1884 KB Output is correct
27 Correct 2 ms 1884 KB Output is correct
28 Correct 9 ms 2612 KB Output is correct
29 Correct 33 ms 4588 KB Output is correct
30 Correct 7 ms 2392 KB Output is correct
31 Correct 15 ms 3256 KB Output is correct
32 Correct 11 ms 2908 KB Output is correct
33 Correct 56 ms 7388 KB Output is correct
34 Correct 26 ms 4944 KB Output is correct
35 Correct 25 ms 3932 KB Output is correct
36 Correct 3 ms 2140 KB Output is correct
37 Correct 13 ms 3420 KB Output is correct
38 Correct 16 ms 3932 KB Output is correct
39 Correct 13 ms 3280 KB Output is correct
40 Correct 12 ms 3420 KB Output is correct
41 Correct 14 ms 3676 KB Output is correct
42 Correct 8 ms 2168 KB Output is correct
43 Correct 10 ms 2268 KB Output is correct
44 Correct 9 ms 2140 KB Output is correct
45 Correct 319 ms 24448 KB Output is correct
46 Correct 145 ms 16680 KB Output is correct
47 Correct 14 ms 4188 KB Output is correct
48 Correct 9 ms 2908 KB Output is correct
49 Correct 13 ms 2936 KB Output is correct
50 Correct 9 ms 2652 KB Output is correct
51 Correct 40 ms 5640 KB Output is correct
52 Correct 46 ms 5824 KB Output is correct
53 Correct 15 ms 3416 KB Output is correct
54 Correct 4 ms 2392 KB Output is correct
55 Correct 7 ms 2904 KB Output is correct
56 Correct 22 ms 3480 KB Output is correct
57 Correct 2 ms 1884 KB Output is correct
58 Correct 28 ms 5000 KB Output is correct
59 Correct 26 ms 4692 KB Output is correct
60 Correct 26 ms 4600 KB Output is correct
61 Correct 25 ms 4700 KB Output is correct
62 Correct 291 ms 22224 KB Output is correct
63 Execution timed out 1027 ms 63928 KB Time limit exceeded
64 Halted 0 ms 0 KB -