| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 241449 | maximath_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++11 | 227 ms | 67940 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*D10-4 (100)*/
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int> >adj[30005];
set<int> building[30005];
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >pq;
int n, m, st, ed, dist[30005];
int ans=1e9+69;
int main(){
scanf("%d%d", &n, &m);
int b, p;
scanf("%d%d", &st, &p); building[st].insert(p);
scanf("%d%d", &ed, &p); building[ed].insert(p);
for(int i=2; i<m; i++){
scanf("%d%d", &b, &p);
building[b].insert(p);
}
for(int i=0; i<n; i++) for(int p:building[i]){
for(int j=1; i+j*p<n; j++){
adj[i].push_back({i+j*p, j});
if(building[i+j*p].count(p)) break;
}
for(int j=1; i-j*p>=0; j++){
adj[i].push_back({i-j*p, j});
if(building[i-j*p].count(p)) break;
}
}
for(int i=0; i<n; i++) dist[i]=1e9+69;
pq.push({0, st}); dist[st]=0;
for(;!pq.empty();){
int dst=pq.top().first, nw=pq.top().second;
pq.pop();
if(dist[nw]!=dst) continue;
if(nw==ed) ans=min(ans, dst);
for(pair<int, int> nx:adj[nw]){
if(dist[nx.first]>dist[nw]+nx.second){
dist[nx.first]=dist[nw]+nx.second;
pq.push({dist[nx.first], nx.first});
}
}
}
if(ans==1e9+69) ans=-1;
printf("%d\n", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
