# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470132 | 2021-09-03T05:13:55 Z | robell | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1000 ms | 66172 KB |
#pragma GCC optimize("O2") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; typedef long long ll; #define pb push_back #define eb emplace_back #define countbits __builtin_popcount #define beg0 __builtin_clz #define terminal0 __builtin_ctz int mod = 1e9+7; void setIO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void setIO(string f){ freopen((f+".in").c_str(),"r",stdin); freopen((f+".out").c_str(),"w",stdout); setIO(); } int N, M; vector<vector<pair<int,int>>> l; vector<pair<int,int>> m; int main(){ setIO(); cin >> N >> M; for (int i=0;i<M;i++) l.pb(vector<pair<int,int>>()); for (int i=0;i<M;i++){ int pos; cin >> pos; int moves; cin >> moves; m.pb({pos,moves}); } for (int i=0;i<M;i++){ for (int j=0;j<M;j++){ if (i==j) continue; if (abs(m[j].first-m[i].first)%m[i].second==0){ l[i].pb({j,abs(m[j].first-m[i].first)/m[i].second}); } } } int dp[M]; for (int i=0;i<M;i++){dp[i]=1e9;} priority_queue<pair<int,int>> pq; pq.push({0,0}); while (!pq.empty()){ int dist = -pq.top().first; int ind = pq.top().second; pq.pop(); if (dp[ind]<dist) continue; dp[ind]=dist; for (pair<int,int> a:l[ind]){ if (dp[a.first]>a.second+dist){ pq.push({-(a.second+dist),a.first}); } } } if (dp[1]==1e9){ cout << "-1\n"; }else cout << dp[1] << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Execution timed out | 1097 ms | 66168 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Execution timed out | 1101 ms | 66172 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Execution timed out | 1101 ms | 66164 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Execution timed out | 1096 ms | 66124 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |