제출 #450529

#제출 시각아이디문제언어결과실행 시간메모리
450529Blobo2_Blobo2Jakarta Skyscrapers (APIO15_skyscraper)C++14
57 / 100
1101 ms86160 KiB
/* 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")*/#pragma GCC optimization ("O3") #pragma GCC optimize("Ofast") #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; map<pair<int,int>,int>mp; 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(mp[{j,x.second}])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(mp[{j,x.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; }

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp:10: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   10 | #pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")*/#pragma GCC optimization ("O3")
      | 
skyscraper.cpp:20:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   20 | const int mo=1e9+7,INF=1e18;
      |                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...