# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
873682 | 2023-11-15T13:10:46 Z | andrei_boaca | Sky Walking (IOI19_walk) | C++17 | 645 ms | 280000 KB |
#include "walk.h" #include <bits/stdc++.h> //#include "grader.cpp" #pragma GCC optimize ("Ofast") #pragma GCC optimize ("fast-math") #pragma GCC optimize ("unroll-loops") using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef pair<int,int> pii; const ll INF=1e18; int n; int ind; unordered_map<int,int> f[100005]; vector<pii> muchii[1000005]; vector<pii> nodes[1000005]; ll dist[1000005]; void addnode(int x,int y) { if(f[x][y]!=0) return; ind++; f[x][y]=ind; nodes[x].push_back({y,ind}); } bool use[1000005]; void bfs() { for(int i=1;i<=ind;i++) dist[i]=INF; dist[1]=0; queue<pll> pq; pq.push({0,1}); while(!pq.empty()) { int nod=pq.front().second; pq.pop(); if(use[nod]) continue; use[nod]=1; for(auto i:muchii[nod]) if(dist[i.first]>dist[nod]+i.second) { dist[i.first]=dist[nod]+i.second; pq.push({dist[i.first],i.first}); } } } long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) { n=x.size(); addnode(s,0); addnode(g,0); for(int i=0;i<l.size();i++) { int prv=-1; for(int j=l[i];j<=r[i];j++) if(y[i]<=h[j]) { addnode(j,y[i]); if(prv!=-1) { int a=f[prv][y[i]]; int b=f[j][y[i]]; muchii[a].push_back({b,x[j]-x[prv]}); muchii[b].push_back({a,x[j]-x[prv]}); } prv=j; } } for(int i=0;i<n;i++) if(!nodes[i].empty()) { sort(nodes[i].begin(),nodes[i].end()); for(int j=1;j<nodes[i].size();j++) { ll d=nodes[i][j].first-nodes[i][j-1].first; ll a=nodes[i][j].second; ll b=nodes[i][j-1].second; muchii[a].push_back({b,d}); muchii[b].push_back({a,d}); } } bfs(); if(dist[2]==INF) return -1; return dist[2]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 55132 KB | Output is correct |
2 | Correct | 12 ms | 55132 KB | Output is correct |
3 | Correct | 12 ms | 55132 KB | Output is correct |
4 | Correct | 12 ms | 55132 KB | Output is correct |
5 | Correct | 14 ms | 55388 KB | Output is correct |
6 | Correct | 12 ms | 55388 KB | Output is correct |
7 | Correct | 12 ms | 55292 KB | Output is correct |
8 | Correct | 12 ms | 55388 KB | Output is correct |
9 | Correct | 12 ms | 55388 KB | Output is correct |
10 | Correct | 12 ms | 55388 KB | Output is correct |
11 | Correct | 12 ms | 55640 KB | Output is correct |
12 | Correct | 12 ms | 55388 KB | Output is correct |
13 | Correct | 12 ms | 55132 KB | Output is correct |
14 | Correct | 13 ms | 55356 KB | Output is correct |
15 | Correct | 13 ms | 55276 KB | Output is correct |
16 | Correct | 12 ms | 55312 KB | Output is correct |
17 | Correct | 12 ms | 55640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 55128 KB | Output is correct |
2 | Correct | 12 ms | 55132 KB | Output is correct |
3 | Correct | 645 ms | 153312 KB | Output is correct |
4 | Incorrect | 499 ms | 153368 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 64080 KB | Output is correct |
2 | Runtime error | 435 ms | 280000 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 64080 KB | Output is correct |
2 | Runtime error | 435 ms | 280000 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 55132 KB | Output is correct |
2 | Correct | 12 ms | 55132 KB | Output is correct |
3 | Correct | 12 ms | 55132 KB | Output is correct |
4 | Correct | 12 ms | 55132 KB | Output is correct |
5 | Correct | 14 ms | 55388 KB | Output is correct |
6 | Correct | 12 ms | 55388 KB | Output is correct |
7 | Correct | 12 ms | 55292 KB | Output is correct |
8 | Correct | 12 ms | 55388 KB | Output is correct |
9 | Correct | 12 ms | 55388 KB | Output is correct |
10 | Correct | 12 ms | 55388 KB | Output is correct |
11 | Correct | 12 ms | 55640 KB | Output is correct |
12 | Correct | 12 ms | 55388 KB | Output is correct |
13 | Correct | 12 ms | 55132 KB | Output is correct |
14 | Correct | 13 ms | 55356 KB | Output is correct |
15 | Correct | 13 ms | 55276 KB | Output is correct |
16 | Correct | 12 ms | 55312 KB | Output is correct |
17 | Correct | 12 ms | 55640 KB | Output is correct |
18 | Correct | 12 ms | 55128 KB | Output is correct |
19 | Correct | 12 ms | 55132 KB | Output is correct |
20 | Correct | 645 ms | 153312 KB | Output is correct |
21 | Incorrect | 499 ms | 153368 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |