# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72721 | 2018-08-26T20:51:10 Z | Pajaraja | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 5 ms | 3024 KB |
#include <bits/stdc++.h> #define MAXN 30007 using namespace std; vector<int> g[MAXN],w[MAXN],v[MAXN],c; bool vi[MAXN]; int dist[MAXN]; void dijkstra(int s) { priority_queue<pair<int,int> > pq; pq.push(make_pair(0,s)); while(!pq.empty()) { int u=pq.top().second,d=-pq.top().first; pq.pop(); if(vi[u]) continue; dist[u]=d; vi[u]=true; for(int i=0;i<g[u].size();i++) if(!vi[g[u][i]]) pq.push(make_pair(-d-w[u][i],g[u][i])); } } bool binarna(int l,int r,int k,int val) { if(r<l) return false; int s=(l+r)/2; if(v[k][s]==val) return true; if(val<v[k][s]) return binarna(l,s-1,k,val); return binarna(s+1,r,k,val); } int main() { int n,m,st,en,t1,t2; scanf("%d%d",&n,&m); scanf("%d%d%d%d",&st,&t1,&en,&t2); v[st].push_back(t1); v[en].push_back(t2); for(int i=0;i<m-2;i++) { scanf("%d%d",&t1,&t2); v[t1].push_back(t2); } for(int i=0;i<n;i++) sort(v[i].begin(),v[i].end()); for(int i=0;i<n;i++) { for(int j=v[i].size()-1;j>=0;j--) { int t=v[i][j],cur=i+t,cnt=0; while(cur<n) { cnt++; if(!vi[cur]) { g[i].push_back(cur); w[i].push_back(cnt); vi[cur]=true; c.push_back(cur); } if(binarna(0,v[cur].size()-1,cur,t)) break; cur+=t; } cur=i-t; cnt=0; while(cur>=0) { cnt++; if(!vi[cur]) { g[i].push_back(cur); w[i].push_back(cnt); vi[cur]=true; c.push_back(cur); } if(binarna(0,v[cur].size()-1,cur,t)) break; cur-=t; } } for(int j=0;j<c.size();j++) vi[c[j]]=false; c.clear(); } dijkstra(st); printf("%d",dist[en]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2552 KB | Output is correct |
2 | Correct | 3 ms | 2672 KB | Output is correct |
3 | Correct | 3 ms | 2780 KB | Output is correct |
4 | Incorrect | 4 ms | 2780 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2816 KB | Output is correct |
2 | Correct | 4 ms | 2820 KB | Output is correct |
3 | Correct | 3 ms | 2952 KB | Output is correct |
4 | Incorrect | 4 ms | 2952 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2952 KB | Output is correct |
2 | Correct | 3 ms | 2952 KB | Output is correct |
3 | Correct | 4 ms | 2952 KB | Output is correct |
4 | Incorrect | 4 ms | 2996 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2996 KB | Output is correct |
2 | Correct | 4 ms | 2996 KB | Output is correct |
3 | Correct | 4 ms | 2996 KB | Output is correct |
4 | Incorrect | 5 ms | 2996 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2996 KB | Output is correct |
2 | Correct | 4 ms | 2996 KB | Output is correct |
3 | Correct | 4 ms | 3016 KB | Output is correct |
4 | Incorrect | 5 ms | 3024 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |