Submission #1110673

# Submission time Handle Problem Language Result Execution time Memory
1110673 2024-11-10T07:35:05 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
105 ms 11600 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
const int BLOCK=226;
int m,n,s,t,u,vv;
int dp[50005];
bool check[50005][BLOCK+5];
vector<int> g[50005];
struct jakarta
{
    int v,p,w;
    jakarta(int v,int p,int w): v(v),p(p),w(w) {}
};
queue<jakarta> Q;
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (int i=0;i<m;++i)
    {
        cin>>u>>vv;
        g[u].push_back(vv);
        if (i==0)
        {
            s=u;
        }
        if (i==1)
        {
            t=u;
        }
    }
    memset(dp,-1,sizeof dp);
    Q.emplace(s,0,0);
    while (Q.size())
    {
        jakarta hao=Q.front();
        Q.pop();
        if (hao.v<0 || hao.v>=n) continue;
        if (abs(hao.p)<BLOCK)
        {
            if (check[hao.v][abs(hao.p)]) continue;
            check[hao.v][abs(hao.p)]=1;
        }
        if (dp[hao.v]==-1)
        {
            dp[hao.v]=hao.w;
            for (auto it: g[hao.v])
            {
                Q.emplace(hao.v+it,it,hao.w+1);
                Q.emplace(hao.v-it,-it,hao.w+1);
            }
        }
        Q.emplace(hao.v+hao.p,hao.p,hao.w+1);
    }
    cout<<dp[t];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 1 ms 4688 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4688 KB Output is correct
7 Correct 2 ms 4688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4688 KB Output is correct
2 Correct 2 ms 4688 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 1 ms 4688 KB Output is correct
7 Correct 1 ms 4688 KB Output is correct
8 Correct 2 ms 4688 KB Output is correct
9 Correct 2 ms 4688 KB Output is correct
10 Correct 2 ms 4856 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 2 ms 5112 KB Output is correct
13 Correct 2 ms 4944 KB Output is correct
14 Correct 3 ms 4944 KB Output is correct
15 Correct 2 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4688 KB Output is correct
3 Correct 1 ms 4688 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4700 KB Output is correct
7 Correct 2 ms 4688 KB Output is correct
8 Correct 2 ms 4688 KB Output is correct
9 Correct 1 ms 4688 KB Output is correct
10 Correct 2 ms 5112 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 2 ms 4944 KB Output is correct
13 Correct 2 ms 4944 KB Output is correct
14 Correct 2 ms 4944 KB Output is correct
15 Correct 2 ms 4944 KB Output is correct
16 Correct 2 ms 4688 KB Output is correct
17 Correct 2 ms 4944 KB Output is correct
18 Correct 1 ms 4944 KB Output is correct
19 Correct 2 ms 4944 KB Output is correct
20 Correct 2 ms 4944 KB Output is correct
21 Correct 2 ms 4688 KB Output is correct
22 Correct 2 ms 4944 KB Output is correct
23 Correct 2 ms 4944 KB Output is correct
24 Correct 2 ms 4944 KB Output is correct
25 Correct 2 ms 4944 KB Output is correct
26 Correct 2 ms 4944 KB Output is correct
27 Correct 2 ms 4944 KB Output is correct
28 Correct 2 ms 4944 KB Output is correct
29 Correct 2 ms 4944 KB Output is correct
30 Correct 2 ms 4688 KB Output is correct
31 Correct 2 ms 4688 KB Output is correct
32 Correct 2 ms 4688 KB Output is correct
33 Correct 2 ms 4944 KB Output is correct
34 Correct 3 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 1 ms 4688 KB Output is correct
3 Correct 2 ms 4688 KB Output is correct
4 Correct 1 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4688 KB Output is correct
7 Correct 1 ms 4688 KB Output is correct
8 Correct 1 ms 4856 KB Output is correct
9 Correct 1 ms 4688 KB Output is correct
10 Correct 1 ms 4688 KB Output is correct
11 Correct 2 ms 4944 KB Output is correct
12 Correct 2 ms 4944 KB Output is correct
13 Correct 1 ms 4944 KB Output is correct
14 Correct 2 ms 4944 KB Output is correct
15 Correct 2 ms 4944 KB Output is correct
16 Correct 2 ms 4688 KB Output is correct
17 Correct 2 ms 4944 KB Output is correct
18 Correct 2 ms 4944 KB Output is correct
19 Correct 1 ms 4944 KB Output is correct
20 Correct 2 ms 4944 KB Output is correct
21 Correct 2 ms 4688 KB Output is correct
22 Correct 2 ms 4944 KB Output is correct
23 Correct 2 ms 4944 KB Output is correct
24 Correct 2 ms 5200 KB Output is correct
25 Correct 2 ms 5112 KB Output is correct
26 Correct 2 ms 4944 KB Output is correct
27 Correct 2 ms 4944 KB Output is correct
28 Correct 2 ms 4944 KB Output is correct
29 Correct 2 ms 4944 KB Output is correct
30 Correct 3 ms 4688 KB Output is correct
31 Correct 2 ms 4688 KB Output is correct
32 Correct 2 ms 4688 KB Output is correct
33 Correct 2 ms 4944 KB Output is correct
34 Correct 2 ms 4944 KB Output is correct
35 Correct 6 ms 5456 KB Output is correct
36 Correct 2 ms 4944 KB Output is correct
37 Correct 7 ms 5456 KB Output is correct
38 Correct 7 ms 5688 KB Output is correct
39 Correct 9 ms 5712 KB Output is correct
40 Correct 8 ms 5712 KB Output is correct
41 Correct 9 ms 5712 KB Output is correct
42 Correct 7 ms 5712 KB Output is correct
43 Correct 6 ms 5712 KB Output is correct
44 Correct 6 ms 5712 KB Output is correct
45 Correct 10 ms 5712 KB Output is correct
46 Correct 9 ms 5860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4688 KB Output is correct
2 Correct 2 ms 4688 KB Output is correct
3 Correct 2 ms 4860 KB Output is correct
4 Correct 2 ms 4688 KB Output is correct
5 Correct 2 ms 4688 KB Output is correct
6 Correct 2 ms 4688 KB Output is correct
7 Correct 2 ms 4688 KB Output is correct
8 Correct 1 ms 4688 KB Output is correct
9 Correct 2 ms 4688 KB Output is correct
10 Correct 2 ms 4708 KB Output is correct
11 Correct 3 ms 4944 KB Output is correct
12 Correct 2 ms 4944 KB Output is correct
13 Correct 2 ms 4944 KB Output is correct
14 Correct 2 ms 4944 KB Output is correct
15 Correct 2 ms 4944 KB Output is correct
16 Correct 2 ms 4688 KB Output is correct
17 Correct 2 ms 4944 KB Output is correct
18 Correct 2 ms 4944 KB Output is correct
19 Correct 2 ms 4944 KB Output is correct
20 Correct 1 ms 4944 KB Output is correct
21 Correct 2 ms 4688 KB Output is correct
22 Correct 2 ms 4944 KB Output is correct
23 Correct 2 ms 4944 KB Output is correct
24 Correct 2 ms 4944 KB Output is correct
25 Correct 2 ms 4944 KB Output is correct
26 Correct 2 ms 4944 KB Output is correct
27 Correct 2 ms 4948 KB Output is correct
28 Correct 2 ms 4944 KB Output is correct
29 Correct 2 ms 4944 KB Output is correct
30 Correct 2 ms 4856 KB Output is correct
31 Correct 2 ms 4856 KB Output is correct
32 Correct 2 ms 4688 KB Output is correct
33 Correct 3 ms 4944 KB Output is correct
34 Correct 3 ms 4944 KB Output is correct
35 Correct 7 ms 5468 KB Output is correct
36 Correct 3 ms 4944 KB Output is correct
37 Correct 7 ms 5456 KB Output is correct
38 Correct 8 ms 5712 KB Output is correct
39 Correct 10 ms 5712 KB Output is correct
40 Correct 8 ms 5712 KB Output is correct
41 Correct 8 ms 5712 KB Output is correct
42 Correct 5 ms 5712 KB Output is correct
43 Correct 6 ms 5880 KB Output is correct
44 Correct 5 ms 5712 KB Output is correct
45 Correct 10 ms 5712 KB Output is correct
46 Correct 10 ms 5712 KB Output is correct
47 Correct 14 ms 7504 KB Output is correct
48 Correct 5 ms 5200 KB Output is correct
49 Correct 5 ms 5200 KB Output is correct
50 Correct 4 ms 5428 KB Output is correct
51 Correct 17 ms 11316 KB Output is correct
52 Correct 24 ms 11336 KB Output is correct
53 Correct 13 ms 11088 KB Output is correct
54 Correct 6 ms 10828 KB Output is correct
55 Correct 6 ms 10528 KB Output is correct
56 Correct 11 ms 11500 KB Output is correct
57 Correct 14 ms 10604 KB Output is correct
58 Correct 9 ms 11344 KB Output is correct
59 Correct 11 ms 11344 KB Output is correct
60 Correct 11 ms 11344 KB Output is correct
61 Correct 10 ms 11344 KB Output is correct
62 Correct 22 ms 11600 KB Output is correct
63 Correct 33 ms 11100 KB Output is correct
64 Correct 35 ms 11088 KB Output is correct
65 Correct 59 ms 11116 KB Output is correct
66 Correct 100 ms 11484 KB Output is correct
67 Correct 105 ms 11336 KB Output is correct