# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
34836 | 2017-11-16T05:36:56 Z | simotion | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 0 ms | 2016 KB |
#include <bits/stdc++.h> #define ll long long #define mp make_pair #define pi pair<int,int> #define fi first #define se second #define SIZ 31 #define INF 1e9 using namespace std; int n,m; int b[SIZ],p[SIZ]; int t1,t2; bool visited[SIZ]; int dist[SIZ]; int main() { scanf("%d %d",&n,&m); for(int i=0;i<m;i++) { scanf("%d %d",&b[i],&p[i]); dist[i]=INF; } dist[0]=0; priority_queue<pi,vector<pi >,greater<pi > > pq; pq.push(mp(0,0)); while(!pq.empty()&&!visited[1]) { auto now=pq.top(); pq.pop(); if(visited[now.se]) continue; visited[now.se]=true; int loc=b[now.se],jmp=p[now.se]; for(int i=0;i<m;i++) { if(loc!=b[i]&&abs(loc-b[i])%jmp==0) { int cand=now.fi+abs(loc-b[i])/jmp; pq.push(mp(cand,i)); dist[i]=min(dist[i],cand); } } } if(!visited[1]) printf("-1"); else printf("%d",dist[1]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |