Submission #315869

# Submission time Handle Problem Language Result Execution time Memory
315869 2020-10-24T08:01:12 Z ewwdsgfvsd Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 4728 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define F first
#define S second
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=5e4+10,LN=30,SQ=550,M=1e5+10;
const ll INF=1e15;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,m,s,t,h[N];
vector<ll> adj[N];
priority_queue<pll> q;
int main(){
    fast_io;
    cin >> n >> m;
    for(ll i=0; i<m; i++){
        ll b,p;
        cin >> b >> p;
        if(i==0) s=b;
        if(i==1) t=b;
        adj[b].push_back(p);
    }
    memset(h,63,sizeof h);
    h[s]=0;
    q.push({0,s});
    while(!q.empty()){
        ll v=q.top().S,x=-q.top().F;
        q.pop();
        if(h[v]<x) continue;
        for(ll t : adj[v]){
            for(ll u=v-t,j=1; u>=0; u-=t,j++){
                if(h[u]<=x+j) continue;
                h[u]=x+j;
                q.push({-h[u],u});
            }
            for(ll u=v+t,j=1; u<n; u+=t,j++){
                if(h[u]<=x+j) continue;
                h[u]=x+j;
                q.push({-h[u],u});
            }
        }
    }
    if(h[t]<=INF) cout << h[t] << '\n';
    else cout << -1 << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1920 KB Output is correct
2 Correct 1 ms 1920 KB Output is correct
3 Correct 1 ms 1920 KB Output is correct
4 Correct 1 ms 1920 KB Output is correct
5 Correct 2 ms 1920 KB Output is correct
6 Correct 1 ms 1920 KB Output is correct
7 Correct 1 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1920 KB Output is correct
2 Correct 1 ms 1920 KB Output is correct
3 Correct 1 ms 1920 KB Output is correct
4 Correct 2 ms 1920 KB Output is correct
5 Correct 1 ms 1920 KB Output is correct
6 Correct 2 ms 1920 KB Output is correct
7 Correct 1 ms 1920 KB Output is correct
8 Correct 1 ms 1920 KB Output is correct
9 Correct 1 ms 1920 KB Output is correct
10 Correct 2 ms 1920 KB Output is correct
11 Correct 2 ms 1920 KB Output is correct
12 Correct 2 ms 1920 KB Output is correct
13 Correct 2 ms 1920 KB Output is correct
14 Correct 2 ms 1920 KB Output is correct
15 Correct 2 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1920 KB Output is correct
2 Correct 1 ms 1920 KB Output is correct
3 Correct 1 ms 1920 KB Output is correct
4 Correct 1 ms 1920 KB Output is correct
5 Correct 2 ms 1920 KB Output is correct
6 Correct 2 ms 2048 KB Output is correct
7 Correct 1 ms 1920 KB Output is correct
8 Correct 1 ms 1920 KB Output is correct
9 Correct 2 ms 1920 KB Output is correct
10 Correct 2 ms 1920 KB Output is correct
11 Correct 2 ms 1920 KB Output is correct
12 Correct 2 ms 1920 KB Output is correct
13 Correct 2 ms 1828 KB Output is correct
14 Correct 2 ms 1920 KB Output is correct
15 Correct 2 ms 1920 KB Output is correct
16 Correct 2 ms 1920 KB Output is correct
17 Correct 2 ms 1920 KB Output is correct
18 Correct 2 ms 1920 KB Output is correct
19 Correct 2 ms 1920 KB Output is correct
20 Correct 7 ms 2048 KB Output is correct
21 Correct 2 ms 1920 KB Output is correct
22 Correct 2 ms 1920 KB Output is correct
23 Correct 2 ms 1920 KB Output is correct
24 Correct 3 ms 2048 KB Output is correct
25 Correct 2 ms 2048 KB Output is correct
26 Correct 6 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 2 ms 1920 KB Output is correct
29 Correct 3 ms 2176 KB Output is correct
30 Correct 2 ms 2048 KB Output is correct
31 Correct 2 ms 2048 KB Output is correct
32 Correct 2 ms 2048 KB Output is correct
33 Correct 3 ms 2176 KB Output is correct
34 Correct 4 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1920 KB Output is correct
2 Correct 1 ms 1920 KB Output is correct
3 Correct 1 ms 1920 KB Output is correct
4 Correct 2 ms 1920 KB Output is correct
5 Correct 1 ms 1920 KB Output is correct
6 Correct 2 ms 1920 KB Output is correct
7 Correct 2 ms 1920 KB Output is correct
8 Correct 1 ms 1920 KB Output is correct
9 Correct 1 ms 1920 KB Output is correct
10 Correct 2 ms 1920 KB Output is correct
11 Correct 2 ms 1920 KB Output is correct
12 Correct 3 ms 1920 KB Output is correct
13 Correct 2 ms 1920 KB Output is correct
14 Correct 2 ms 1920 KB Output is correct
15 Correct 2 ms 1920 KB Output is correct
16 Correct 2 ms 1920 KB Output is correct
17 Correct 2 ms 2048 KB Output is correct
18 Correct 2 ms 1920 KB Output is correct
19 Correct 2 ms 1920 KB Output is correct
20 Correct 7 ms 2048 KB Output is correct
21 Correct 2 ms 1920 KB Output is correct
22 Correct 1 ms 1920 KB Output is correct
23 Correct 2 ms 2048 KB Output is correct
24 Correct 2 ms 2048 KB Output is correct
25 Correct 3 ms 2048 KB Output is correct
26 Correct 6 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 2 ms 1920 KB Output is correct
29 Correct 3 ms 2176 KB Output is correct
30 Correct 2 ms 2048 KB Output is correct
31 Correct 2 ms 2084 KB Output is correct
32 Correct 2 ms 2048 KB Output is correct
33 Correct 4 ms 2176 KB Output is correct
34 Correct 3 ms 2304 KB Output is correct
35 Correct 8 ms 2304 KB Output is correct
36 Correct 3 ms 2048 KB Output is correct
37 Correct 7 ms 2432 KB Output is correct
38 Correct 10 ms 2560 KB Output is correct
39 Correct 9 ms 2560 KB Output is correct
40 Correct 10 ms 2560 KB Output is correct
41 Correct 10 ms 2560 KB Output is correct
42 Correct 68 ms 2304 KB Output is correct
43 Correct 69 ms 2304 KB Output is correct
44 Correct 66 ms 2340 KB Output is correct
45 Correct 8 ms 2432 KB Output is correct
46 Correct 8 ms 2464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1920 KB Output is correct
2 Correct 1 ms 1920 KB Output is correct
3 Correct 1 ms 1920 KB Output is correct
4 Correct 1 ms 1920 KB Output is correct
5 Correct 1 ms 1920 KB Output is correct
6 Correct 1 ms 1920 KB Output is correct
7 Correct 1 ms 1920 KB Output is correct
8 Correct 2 ms 1920 KB Output is correct
9 Correct 1 ms 1920 KB Output is correct
10 Correct 2 ms 1920 KB Output is correct
11 Correct 3 ms 2048 KB Output is correct
12 Correct 2 ms 1920 KB Output is correct
13 Correct 2 ms 1920 KB Output is correct
14 Correct 2 ms 1920 KB Output is correct
15 Correct 2 ms 1920 KB Output is correct
16 Correct 2 ms 1920 KB Output is correct
17 Correct 3 ms 1920 KB Output is correct
18 Correct 2 ms 1920 KB Output is correct
19 Correct 2 ms 1920 KB Output is correct
20 Correct 7 ms 2048 KB Output is correct
21 Correct 2 ms 1920 KB Output is correct
22 Correct 2 ms 1920 KB Output is correct
23 Correct 2 ms 1920 KB Output is correct
24 Correct 3 ms 2048 KB Output is correct
25 Correct 2 ms 2048 KB Output is correct
26 Correct 5 ms 1920 KB Output is correct
27 Correct 7 ms 2048 KB Output is correct
28 Correct 2 ms 1920 KB Output is correct
29 Correct 3 ms 2176 KB Output is correct
30 Correct 2 ms 2048 KB Output is correct
31 Correct 2 ms 2084 KB Output is correct
32 Correct 2 ms 2048 KB Output is correct
33 Correct 3 ms 2176 KB Output is correct
34 Correct 3 ms 2304 KB Output is correct
35 Correct 8 ms 2304 KB Output is correct
36 Correct 3 ms 2048 KB Output is correct
37 Correct 7 ms 2432 KB Output is correct
38 Correct 9 ms 2560 KB Output is correct
39 Correct 9 ms 2560 KB Output is correct
40 Correct 10 ms 2560 KB Output is correct
41 Correct 9 ms 2560 KB Output is correct
42 Correct 65 ms 2304 KB Output is correct
43 Correct 72 ms 2304 KB Output is correct
44 Correct 67 ms 2340 KB Output is correct
45 Correct 8 ms 2432 KB Output is correct
46 Correct 8 ms 2560 KB Output is correct
47 Correct 18 ms 3452 KB Output is correct
48 Correct 9 ms 2432 KB Output is correct
49 Correct 9 ms 2304 KB Output is correct
50 Correct 5 ms 2304 KB Output is correct
51 Correct 31 ms 4728 KB Output is correct
52 Correct 29 ms 3708 KB Output is correct
53 Correct 16 ms 3708 KB Output is correct
54 Correct 3 ms 2304 KB Output is correct
55 Correct 3 ms 2304 KB Output is correct
56 Execution timed out 1095 ms 3456 KB Time limit exceeded
57 Halted 0 ms 0 KB -