# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
612627 | 2022-07-29T18:29:50 Z | krit3379 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 891 ms | 224872 KB |
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 30005 struct A{ unsigned short a,b; }; int a[N],p[N],f,b; vector<int> g[N]; bitset<N> vis; gp_hash_table<int,int> s[N]; A arr[8000000]; int main(){ int n,m,i; scanf("%d %d",&n,&m); for(i=0;i<m;i++){ scanf("%d %d",&a[i],&p[i]); g[a[i]].push_back(p[i]); } arr[0]={a[0],p[0]}; s[a[0]][p[0]]=0; while(f<=b){ auto [u,i]=arr[f++]; int x=u,po=i,w=s[x][po]; if(x==a[1]){printf("%d",w);return 0;} if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po},s[x-po][po]=w+1; if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po},s[x+po][po]=w+1; if(vis[x])continue; vis[x]=true; for(auto po:g[x]){ if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po},s[x-po][po]=w+1; if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po},s[x+po][po]=w+1; } } printf("-1"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7252 KB | Output is correct |
2 | Correct | 6 ms | 7264 KB | Output is correct |
3 | Correct | 6 ms | 7252 KB | Output is correct |
4 | Correct | 7 ms | 7380 KB | Output is correct |
5 | Correct | 6 ms | 7252 KB | Output is correct |
6 | Correct | 5 ms | 7252 KB | Output is correct |
7 | Correct | 6 ms | 7252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7252 KB | Output is correct |
2 | Correct | 6 ms | 7252 KB | Output is correct |
3 | Correct | 5 ms | 7252 KB | Output is correct |
4 | Correct | 7 ms | 7252 KB | Output is correct |
5 | Correct | 6 ms | 7252 KB | Output is correct |
6 | Correct | 6 ms | 7344 KB | Output is correct |
7 | Correct | 6 ms | 7368 KB | Output is correct |
8 | Correct | 6 ms | 7252 KB | Output is correct |
9 | Correct | 6 ms | 7252 KB | Output is correct |
10 | Correct | 7 ms | 7268 KB | Output is correct |
11 | Correct | 6 ms | 7380 KB | Output is correct |
12 | Correct | 6 ms | 7380 KB | Output is correct |
13 | Correct | 7 ms | 7380 KB | Output is correct |
14 | Correct | 7 ms | 7508 KB | Output is correct |
15 | Correct | 7 ms | 7380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 7252 KB | Output is correct |
2 | Correct | 7 ms | 7252 KB | Output is correct |
3 | Correct | 6 ms | 7256 KB | Output is correct |
4 | Correct | 7 ms | 7252 KB | Output is correct |
5 | Correct | 6 ms | 7252 KB | Output is correct |
6 | Correct | 6 ms | 7364 KB | Output is correct |
7 | Correct | 6 ms | 7252 KB | Output is correct |
8 | Correct | 6 ms | 7320 KB | Output is correct |
9 | Correct | 5 ms | 7252 KB | Output is correct |
10 | Correct | 6 ms | 7252 KB | Output is correct |
11 | Correct | 6 ms | 7380 KB | Output is correct |
12 | Correct | 7 ms | 7380 KB | Output is correct |
13 | Correct | 7 ms | 7336 KB | Output is correct |
14 | Correct | 7 ms | 7584 KB | Output is correct |
15 | Correct | 6 ms | 7380 KB | Output is correct |
16 | Correct | 6 ms | 7328 KB | Output is correct |
17 | Correct | 6 ms | 7508 KB | Output is correct |
18 | Correct | 6 ms | 7380 KB | Output is correct |
19 | Correct | 6 ms | 7380 KB | Output is correct |
20 | Correct | 7 ms | 7380 KB | Output is correct |
21 | Correct | 6 ms | 7380 KB | Output is correct |
22 | Correct | 6 ms | 7380 KB | Output is correct |
23 | Correct | 6 ms | 7508 KB | Output is correct |
24 | Correct | 7 ms | 7508 KB | Output is correct |
25 | Correct | 7 ms | 7380 KB | Output is correct |
26 | Correct | 6 ms | 7380 KB | Output is correct |
27 | Correct | 6 ms | 7380 KB | Output is correct |
28 | Correct | 9 ms | 8020 KB | Output is correct |
29 | Correct | 11 ms | 9812 KB | Output is correct |
30 | Correct | 8 ms | 7892 KB | Output is correct |
31 | Correct | 9 ms | 8844 KB | Output is correct |
32 | Correct | 8 ms | 8092 KB | Output is correct |
33 | Correct | 15 ms | 11476 KB | Output is correct |
34 | Correct | 13 ms | 9524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7252 KB | Output is correct |
2 | Correct | 7 ms | 7252 KB | Output is correct |
3 | Correct | 6 ms | 7252 KB | Output is correct |
4 | Correct | 6 ms | 7252 KB | Output is correct |
5 | Correct | 6 ms | 7252 KB | Output is correct |
6 | Correct | 8 ms | 7252 KB | Output is correct |
7 | Correct | 6 ms | 7252 KB | Output is correct |
8 | Correct | 8 ms | 7380 KB | Output is correct |
9 | Correct | 6 ms | 7264 KB | Output is correct |
10 | Correct | 6 ms | 7252 KB | Output is correct |
11 | Correct | 6 ms | 7380 KB | Output is correct |
12 | Correct | 8 ms | 7380 KB | Output is correct |
13 | Correct | 6 ms | 7380 KB | Output is correct |
14 | Correct | 7 ms | 7508 KB | Output is correct |
15 | Correct | 6 ms | 7380 KB | Output is correct |
16 | Correct | 6 ms | 7380 KB | Output is correct |
17 | Correct | 6 ms | 7508 KB | Output is correct |
18 | Correct | 6 ms | 7380 KB | Output is correct |
19 | Correct | 8 ms | 7380 KB | Output is correct |
20 | Correct | 9 ms | 7380 KB | Output is correct |
21 | Correct | 6 ms | 7380 KB | Output is correct |
22 | Correct | 6 ms | 7380 KB | Output is correct |
23 | Correct | 7 ms | 7380 KB | Output is correct |
24 | Correct | 7 ms | 7508 KB | Output is correct |
25 | Correct | 7 ms | 7420 KB | Output is correct |
26 | Correct | 6 ms | 7380 KB | Output is correct |
27 | Correct | 6 ms | 7380 KB | Output is correct |
28 | Correct | 9 ms | 8020 KB | Output is correct |
29 | Correct | 12 ms | 9812 KB | Output is correct |
30 | Correct | 8 ms | 7892 KB | Output is correct |
31 | Correct | 10 ms | 8788 KB | Output is correct |
32 | Correct | 12 ms | 8064 KB | Output is correct |
33 | Correct | 15 ms | 11348 KB | Output is correct |
34 | Correct | 12 ms | 9556 KB | Output is correct |
35 | Correct | 16 ms | 8876 KB | Output is correct |
36 | Correct | 7 ms | 7380 KB | Output is correct |
37 | Correct | 13 ms | 8316 KB | Output is correct |
38 | Correct | 15 ms | 8864 KB | Output is correct |
39 | Correct | 13 ms | 7764 KB | Output is correct |
40 | Correct | 12 ms | 7788 KB | Output is correct |
41 | Correct | 12 ms | 7892 KB | Output is correct |
42 | Correct | 10 ms | 7764 KB | Output is correct |
43 | Correct | 10 ms | 7764 KB | Output is correct |
44 | Correct | 10 ms | 7764 KB | Output is correct |
45 | Correct | 50 ms | 22168 KB | Output is correct |
46 | Correct | 43 ms | 17456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7252 KB | Output is correct |
2 | Correct | 6 ms | 7252 KB | Output is correct |
3 | Correct | 5 ms | 7252 KB | Output is correct |
4 | Correct | 6 ms | 7252 KB | Output is correct |
5 | Correct | 6 ms | 7368 KB | Output is correct |
6 | Correct | 5 ms | 7252 KB | Output is correct |
7 | Correct | 6 ms | 7252 KB | Output is correct |
8 | Correct | 6 ms | 7296 KB | Output is correct |
9 | Correct | 6 ms | 7252 KB | Output is correct |
10 | Correct | 7 ms | 7252 KB | Output is correct |
11 | Correct | 6 ms | 7380 KB | Output is correct |
12 | Correct | 6 ms | 7380 KB | Output is correct |
13 | Correct | 6 ms | 7380 KB | Output is correct |
14 | Correct | 7 ms | 7508 KB | Output is correct |
15 | Correct | 8 ms | 7380 KB | Output is correct |
16 | Correct | 7 ms | 7324 KB | Output is correct |
17 | Correct | 7 ms | 7508 KB | Output is correct |
18 | Correct | 7 ms | 7380 KB | Output is correct |
19 | Correct | 6 ms | 7380 KB | Output is correct |
20 | Correct | 6 ms | 7380 KB | Output is correct |
21 | Correct | 6 ms | 7380 KB | Output is correct |
22 | Correct | 7 ms | 7380 KB | Output is correct |
23 | Correct | 6 ms | 7508 KB | Output is correct |
24 | Correct | 7 ms | 7508 KB | Output is correct |
25 | Correct | 6 ms | 7380 KB | Output is correct |
26 | Correct | 6 ms | 7420 KB | Output is correct |
27 | Correct | 7 ms | 7380 KB | Output is correct |
28 | Correct | 9 ms | 7988 KB | Output is correct |
29 | Correct | 11 ms | 9812 KB | Output is correct |
30 | Correct | 8 ms | 7892 KB | Output is correct |
31 | Correct | 9 ms | 8788 KB | Output is correct |
32 | Correct | 9 ms | 8108 KB | Output is correct |
33 | Correct | 14 ms | 11348 KB | Output is correct |
34 | Correct | 11 ms | 9556 KB | Output is correct |
35 | Correct | 15 ms | 8916 KB | Output is correct |
36 | Correct | 9 ms | 7452 KB | Output is correct |
37 | Correct | 12 ms | 8404 KB | Output is correct |
38 | Correct | 18 ms | 8824 KB | Output is correct |
39 | Correct | 12 ms | 7764 KB | Output is correct |
40 | Correct | 12 ms | 7764 KB | Output is correct |
41 | Correct | 13 ms | 7892 KB | Output is correct |
42 | Correct | 13 ms | 7812 KB | Output is correct |
43 | Correct | 13 ms | 7764 KB | Output is correct |
44 | Correct | 10 ms | 7768 KB | Output is correct |
45 | Correct | 50 ms | 22116 KB | Output is correct |
46 | Correct | 33 ms | 17356 KB | Output is correct |
47 | Correct | 13 ms | 8020 KB | Output is correct |
48 | Correct | 12 ms | 8020 KB | Output is correct |
49 | Correct | 12 ms | 7956 KB | Output is correct |
50 | Correct | 11 ms | 7812 KB | Output is correct |
51 | Correct | 23 ms | 8860 KB | Output is correct |
52 | Correct | 25 ms | 9216 KB | Output is correct |
53 | Correct | 16 ms | 8148 KB | Output is correct |
54 | Correct | 6 ms | 7380 KB | Output is correct |
55 | Correct | 7 ms | 7380 KB | Output is correct |
56 | Correct | 15 ms | 8532 KB | Output is correct |
57 | Correct | 7 ms | 7380 KB | Output is correct |
58 | Correct | 16 ms | 8916 KB | Output is correct |
59 | Correct | 14 ms | 8308 KB | Output is correct |
60 | Correct | 14 ms | 8404 KB | Output is correct |
61 | Correct | 14 ms | 8320 KB | Output is correct |
62 | Correct | 112 ms | 24368 KB | Output is correct |
63 | Correct | 518 ms | 108964 KB | Output is correct |
64 | Correct | 690 ms | 112460 KB | Output is correct |
65 | Correct | 770 ms | 196072 KB | Output is correct |
66 | Correct | 891 ms | 224872 KB | Output is correct |
67 | Correct | 463 ms | 139636 KB | Output is correct |