# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
76824 | 2018-09-18T13:11:44 Z | vex | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 3 ms | 1200 KB |
#include <bits/stdc++.h> #define maxn 30005 #define pii pair<int,int> using namespace std; int n,m; vector<int>p[maxn]; priority_queue<pii>pq; int dis[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>m; int s; int e; for(int i=0;i<m;i++) { int x,y; cin>>x>>y; p[x].push_back(y); if(i==0)s=x; if(i==1)e=x; } for(int i=0;i<n;i++)dis[i]=n+30; pq.push({0,s}); dis[s]=0; while(!pq.empty()) { int v=pq.top().second; pq.pop(); for(auto x:p[v]) { for(int i=v%x;i<n;i+=x) { if(dis[i]>dis[v]+(abs(i-v))/x) { dis[i]=dis[v]+abs(i-v)/x; if(i==e) { cout<<dis[i]<<endl; return 0; } pq.push({-dis[i],i}); } } } } cout<<"-1"<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1016 KB | Output is correct |
2 | Incorrect | 3 ms | 1192 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1192 KB | Output is correct |
2 | Incorrect | 3 ms | 1192 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1192 KB | Output is correct |
2 | Incorrect | 2 ms | 1192 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1192 KB | Output is correct |
2 | Incorrect | 3 ms | 1200 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1200 KB | Output is correct |
2 | Incorrect | 3 ms | 1200 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |