답안 #450536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
450536 2021-08-03T01:01:30 Z Blobo2_Blobo2 Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
298 ms 64232 KB
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);

const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}

signed main(){
    Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
    int n=nxt(),m=nxt();
    set<pair<int,int> >st;
    vector<pair<int,int> >v;
    for(int i=0;i<m;i++){
        int b=nxt(),p=nxt();
        if(v.size()<2)v.push_back({b,p});
        st.insert({b,p});
    }
    int from = v[0].first,to = v[1].first;
    vector<pair<int,int> >adj[n+1];
    for(auto x:st){
        for(int j=x.first+x.second;j<n;j+=x.second){
            adj[x.first].push_back({j,(j-x.first)/x.second});
            if(st.find({j,x.second})!=st.end())break;
        }
    }
    for(auto x:st){
        for(int j=x.first-x.second;j>=0;j-=x.second){
            adj[x.first].push_back({j,(x.first-j)/x.second});
            if(st.find({j,x.second})!=st.end())break;
        }
    }
    int dis[n],vis[n];
    for(int i=0;i<n;i++)
        dis[i]=INF,vis[i]=0;
    dis[from]=0;
    priority_queue<pair<int,int> >q;
    q.push({0,from});
    while(!q.empty()) {
        int a=q.top().second;q.pop();
        if(vis[a])continue;
        vis[a]=1;
        for(auto u:adj[a]){
            int b=u.first,w=u.second;
            if(dis[a]+w<dis[b]){
                dis[b]=dis[a]+w;
                q.push({-dis[b],b});
            }
        }
    }
    if(dis[to]==INF)cout<<-1<<endl;
    else cout<<dis[to]<<endl;
    return 0;
}

Compilation message

skyscraper.cpp:19:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int mo=1e9+7,INF=1e18;
      |                        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 3 ms 588 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 3 ms 588 KB Output is correct
25 Correct 3 ms 588 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 4 ms 588 KB Output is correct
29 Correct 4 ms 1100 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 2 ms 844 KB Output is correct
32 Correct 2 ms 712 KB Output is correct
33 Correct 6 ms 1740 KB Output is correct
34 Correct 6 ms 1740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 440 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 3 ms 588 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 3 ms 588 KB Output is correct
25 Correct 2 ms 588 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 4 ms 588 KB Output is correct
29 Correct 4 ms 1100 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 2 ms 716 KB Output is correct
32 Correct 2 ms 716 KB Output is correct
33 Correct 6 ms 1868 KB Output is correct
34 Correct 7 ms 1780 KB Output is correct
35 Correct 32 ms 2536 KB Output is correct
36 Correct 5 ms 716 KB Output is correct
37 Correct 43 ms 3348 KB Output is correct
38 Correct 47 ms 3524 KB Output is correct
39 Correct 49 ms 3552 KB Output is correct
40 Correct 48 ms 3524 KB Output is correct
41 Correct 47 ms 3524 KB Output is correct
42 Correct 6 ms 460 KB Output is correct
43 Correct 6 ms 460 KB Output is correct
44 Correct 7 ms 460 KB Output is correct
45 Correct 36 ms 6040 KB Output is correct
46 Correct 36 ms 6016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 3 ms 588 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 3 ms 588 KB Output is correct
25 Correct 3 ms 588 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 3 ms 588 KB Output is correct
29 Correct 4 ms 1100 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 2 ms 716 KB Output is correct
32 Correct 2 ms 716 KB Output is correct
33 Correct 7 ms 1740 KB Output is correct
34 Correct 7 ms 1740 KB Output is correct
35 Correct 31 ms 2508 KB Output is correct
36 Correct 5 ms 716 KB Output is correct
37 Correct 42 ms 3320 KB Output is correct
38 Correct 49 ms 3508 KB Output is correct
39 Correct 51 ms 3560 KB Output is correct
40 Correct 47 ms 3524 KB Output is correct
41 Correct 51 ms 3488 KB Output is correct
42 Correct 6 ms 460 KB Output is correct
43 Correct 6 ms 460 KB Output is correct
44 Correct 7 ms 460 KB Output is correct
45 Correct 38 ms 6000 KB Output is correct
46 Correct 38 ms 6036 KB Output is correct
47 Correct 165 ms 11112 KB Output is correct
48 Correct 49 ms 4428 KB Output is correct
49 Correct 35 ms 3528 KB Output is correct
50 Correct 29 ms 3292 KB Output is correct
51 Correct 88 ms 6448 KB Output is correct
52 Correct 95 ms 7104 KB Output is correct
53 Correct 31 ms 4168 KB Output is correct
54 Correct 3 ms 1612 KB Output is correct
55 Correct 4 ms 2120 KB Output is correct
56 Correct 23 ms 3532 KB Output is correct
57 Correct 71 ms 10412 KB Output is correct
58 Correct 11 ms 2292 KB Output is correct
59 Correct 12 ms 2540 KB Output is correct
60 Correct 15 ms 3252 KB Output is correct
61 Correct 15 ms 2564 KB Output is correct
62 Correct 93 ms 7704 KB Output is correct
63 Correct 115 ms 24172 KB Output is correct
64 Correct 118 ms 27452 KB Output is correct
65 Correct 160 ms 37192 KB Output is correct
66 Correct 298 ms 64104 KB Output is correct
67 Correct 284 ms 64232 KB Output is correct