Submission #450489

# Submission time Handle Problem Language Result Execution time Memory
450489 2021-08-03T00:28:37 Z Blobo2_Blobo2 Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 6340 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();
    vector<pair<int,int> >v;
    for(int i=0;i<m;i++){
        int b=nxt(),p=nxt();
        v.push_back({b,p});
    }
    int from = v[0].first,to = v[1].first;
    sort(all(v));
    vector<pair<int,int> >adj[n+1];
    for(int i=0;i<v.size();i++){
        for(int j=i+1;j<v.size();j++){
            if(abs(v[i].first-v[j].first)%(v[i].second)==0){
                adj[v[i].first].push_back({v[j].first,abs(v[i].first-v[j].first)/(v[i].second)});
                if(v[i].second==v[j].second)
                    break;
            }
        }
    }
    for(int i=v.size()-1;i>=0;i--){
        for(int j=i-1;j>=0;j--){
            if(abs(v[i].first-v[j].first)%(v[i].second)==0){
                adj[v[i].first].push_back({v[j].first,abs(v[i].first-v[j].first)/(v[i].second)});
                if(v[i].second==v[j].second)
                    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;
      |                        ^~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
skyscraper.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int j=i+1;j<v.size();j++){
      |                       ~^~~~~~~~~
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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 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 19 ms 1412 KB Output is correct
12 Correct 2 ms 716 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 24 ms 1612 KB Output is correct
15 Correct 24 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 20 ms 1468 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 23 ms 1612 KB Output is correct
15 Correct 24 ms 1536 KB Output is correct
16 Correct 5 ms 460 KB Output is correct
17 Correct 19 ms 792 KB Output is correct
18 Correct 6 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 8 ms 332 KB Output is correct
22 Correct 4 ms 332 KB Output is correct
23 Correct 6 ms 396 KB Output is correct
24 Correct 21 ms 460 KB Output is correct
25 Correct 23 ms 476 KB Output is correct
26 Correct 2 ms 716 KB Output is correct
27 Correct 9 ms 4540 KB Output is correct
28 Correct 23 ms 612 KB Output is correct
29 Correct 4 ms 576 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 23 ms 1648 KB Output is correct
34 Correct 24 ms 1676 KB Output is correct
# Verdict Execution time Memory 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 1 ms 204 KB Output is correct
8 Correct 0 ms 232 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 21 ms 1436 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 24 ms 1608 KB Output is correct
15 Correct 24 ms 1612 KB Output is correct
16 Correct 5 ms 460 KB Output is correct
17 Correct 20 ms 768 KB Output is correct
18 Correct 6 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 8 ms 332 KB Output is correct
22 Correct 4 ms 332 KB Output is correct
23 Correct 6 ms 332 KB Output is correct
24 Correct 21 ms 544 KB Output is correct
25 Correct 23 ms 456 KB Output is correct
26 Correct 3 ms 716 KB Output is correct
27 Correct 9 ms 4640 KB Output is correct
28 Correct 23 ms 588 KB Output is correct
29 Correct 4 ms 660 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 24 ms 1716 KB Output is correct
34 Correct 24 ms 1736 KB Output is correct
35 Execution timed out 1091 ms 6340 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 19 ms 1444 KB Output is correct
12 Correct 2 ms 716 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 23 ms 1564 KB Output is correct
15 Correct 24 ms 1544 KB Output is correct
16 Correct 5 ms 460 KB Output is correct
17 Correct 21 ms 716 KB Output is correct
18 Correct 6 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 8 ms 332 KB Output is correct
22 Correct 4 ms 332 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 21 ms 496 KB Output is correct
25 Correct 23 ms 424 KB Output is correct
26 Correct 3 ms 716 KB Output is correct
27 Correct 9 ms 4552 KB Output is correct
28 Correct 23 ms 608 KB Output is correct
29 Correct 4 ms 588 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 23 ms 1728 KB Output is correct
34 Correct 24 ms 1704 KB Output is correct
35 Execution timed out 1085 ms 6316 KB Time limit exceeded
36 Halted 0 ms 0 KB -