# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72739 | 2018-08-26T21:50:54 Z | Pajaraja | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 8 ms | 3584 KB |
#include <bits/stdc++.h> #define MAXN 30007 using namespace std; vector<int> g[MAXN],w[MAXN]; set<int> v[MAXN]; bool vi[MAXN]; int dist[MAXN],en; 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; if(u==en) return; 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,t1,t2; scanf("%d%d",&n,&m); scanf("%d%d%d%d",&st,&t1,&en,&t2); v[st].insert(t1); v[en].insert(t2); for(int i=0;i<m-2;i++) { scanf("%d%d",&t1,&t2); v[t1].insert(t2); } for(int i=0;i<n;i++) { for(set<int>::iterator it=v[i].begin();it!=v[i].end();it++) { int t=*it,cur=i+t; while(cur<n) { if(!vi[cur] && v[cur].size()>0) { g[i].push_back(cur); w[i].push_back((cur-i)/t); vi[cur]=true; } if(v[cur].find(t)!=v[cur].end()) break; cur+=t; } cur=i-t; while(cur>=0) { if(!vi[cur] && v[cur].size()>0) { g[i].push_back(cur); w[i].push_back((i-cur)/t); vi[cur]=true; } if(v[cur].find(t)!=v[cur].end()) break; cur-=t; } } for(int j=0;j<g[i].size();j++) vi[g[i][j]]=false; } dijkstra(st); if(!vi[en]) dist[en]=-1; printf("%d",dist[en]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3192 KB | Output is correct |
2 | Correct | 4 ms | 3192 KB | Output is correct |
3 | Correct | 4 ms | 3252 KB | Output is correct |
4 | Correct | 5 ms | 3308 KB | Output is correct |
5 | Correct | 4 ms | 3360 KB | Output is correct |
6 | Correct | 5 ms | 3360 KB | Output is correct |
7 | Correct | 5 ms | 3360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3360 KB | Output is correct |
2 | Correct | 5 ms | 3360 KB | Output is correct |
3 | Correct | 6 ms | 3360 KB | Output is correct |
4 | Correct | 4 ms | 3360 KB | Output is correct |
5 | Correct | 6 ms | 3436 KB | Output is correct |
6 | Correct | 5 ms | 3436 KB | Output is correct |
7 | Correct | 5 ms | 3452 KB | Output is correct |
8 | Correct | 4 ms | 3452 KB | Output is correct |
9 | Correct | 7 ms | 3556 KB | Output is correct |
10 | Correct | 6 ms | 3556 KB | Output is correct |
11 | Correct | 7 ms | 3556 KB | Output is correct |
12 | Correct | 6 ms | 3556 KB | Output is correct |
13 | Correct | 5 ms | 3556 KB | Output is correct |
14 | Correct | 6 ms | 3556 KB | Output is correct |
15 | Incorrect | 6 ms | 3556 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3556 KB | Output is correct |
2 | Correct | 4 ms | 3556 KB | Output is correct |
3 | Correct | 5 ms | 3556 KB | Output is correct |
4 | Correct | 4 ms | 3556 KB | Output is correct |
5 | Correct | 4 ms | 3556 KB | Output is correct |
6 | Correct | 5 ms | 3556 KB | Output is correct |
7 | Correct | 4 ms | 3556 KB | Output is correct |
8 | Correct | 5 ms | 3556 KB | Output is correct |
9 | Correct | 5 ms | 3556 KB | Output is correct |
10 | Correct | 5 ms | 3556 KB | Output is correct |
11 | Correct | 6 ms | 3556 KB | Output is correct |
12 | Correct | 5 ms | 3556 KB | Output is correct |
13 | Correct | 5 ms | 3556 KB | Output is correct |
14 | Correct | 6 ms | 3556 KB | Output is correct |
15 | Incorrect | 8 ms | 3556 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3556 KB | Output is correct |
2 | Correct | 4 ms | 3556 KB | Output is correct |
3 | Correct | 4 ms | 3556 KB | Output is correct |
4 | Correct | 5 ms | 3556 KB | Output is correct |
5 | Correct | 5 ms | 3556 KB | Output is correct |
6 | Correct | 5 ms | 3556 KB | Output is correct |
7 | Correct | 4 ms | 3556 KB | Output is correct |
8 | Correct | 5 ms | 3556 KB | Output is correct |
9 | Correct | 6 ms | 3576 KB | Output is correct |
10 | Correct | 5 ms | 3576 KB | Output is correct |
11 | Correct | 5 ms | 3576 KB | Output is correct |
12 | Correct | 7 ms | 3576 KB | Output is correct |
13 | Correct | 5 ms | 3576 KB | Output is correct |
14 | Correct | 6 ms | 3576 KB | Output is correct |
15 | Incorrect | 6 ms | 3576 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3576 KB | Output is correct |
2 | Correct | 5 ms | 3576 KB | Output is correct |
3 | Correct | 4 ms | 3576 KB | Output is correct |
4 | Correct | 5 ms | 3576 KB | Output is correct |
5 | Correct | 4 ms | 3576 KB | Output is correct |
6 | Correct | 5 ms | 3576 KB | Output is correct |
7 | Correct | 7 ms | 3576 KB | Output is correct |
8 | Correct | 6 ms | 3576 KB | Output is correct |
9 | Correct | 5 ms | 3576 KB | Output is correct |
10 | Correct | 5 ms | 3584 KB | Output is correct |
11 | Correct | 5 ms | 3584 KB | Output is correct |
12 | Correct | 4 ms | 3584 KB | Output is correct |
13 | Correct | 5 ms | 3584 KB | Output is correct |
14 | Correct | 6 ms | 3584 KB | Output is correct |
15 | Incorrect | 5 ms | 3584 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |