# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
955011 | 2024-03-29T07:27:47 Z | BbtT | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1 ms | 604 KB |
#include<bits/stdc++.h> using namespace std; struct ed{ int n,w; }; bool operator<(ed a,ed b){ return a.w<b.w; } int N,M,d[30005]; bitset<30005> vis; vector<vector<ed>> edge; int main(){ cin>>N>>M; edge.resize(N); for(int i=0;i<M;i++){ int b,p; scanf("%d%d",&b,&p); edge.push_back({}); edge[b].push_back((ed){edge.size()-1,0}); for(int j=b+p;j<N;j+=p){ edge.back().push_back((ed){j,(j-b)/p}); } for(int j=b-p;j>=0;j-=p){ edge.back().push_back((ed){j,(b-j)/p}); } } priority_queue<ed> Q; Q.push((ed){0,0}); while(!Q.empty()){ int cur=Q.top().n,wn=Q.top().w; Q.pop(); vis[cur]=1; for(auto togo:edge[cur]){ if(vis[togo.n])continue; if(d[togo.n]>wn+togo.w||d[togo.n]==0){ d[togo.n]=wn+togo.w; Q.push((ed){togo.n,d[togo.n]}); } } }cout<<d[1]<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 440 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 440 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 1 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 604 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |