# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66656 | 2018-08-12T00:40:21 Z | tincamatei | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 4 ms | 1408 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 30000; vector<pair<int, int> > graph[MAX_N]; bitset<MAX_N> doges[MAX_N]; int dist[MAX_N]; int doggoB[MAX_N], doggoP[MAX_N]; int dijkstra(int n, int src, int dest) { priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq; memset(dist, 0x3f3f3f3f, sizeof(dist)); dist[src] = 0; pq.push(make_pair(0, src)); while(!pq.empty()) { int nod = pq.top().second, distNod = pq.top().first; pq.pop(); if(dist[nod] == distNod) { if(nod == dest) return distNod; for(auto it: graph[nod]) if(distNod + it.second < dist[it.first]) { dist[it.first] = distNod + it.second; pq.push(make_pair(dist[it.first], it.first)); } } } return -1; } int main() { int n, m, b, p, src, dest; scanf("%d%d", &n, &m); for(int i = 0; i < m; ++i) { scanf("%d%d", &doggoB[i], &doggoP[i]); if(i == 0) src = doggoB[i]; if(i == 1) dest = doggoB[i]; doges[b][p] = true; } for(int i = 0; i < m; ++i) { pair<int, int> doge = make_pair(doggoB[i], doggoP[i]); int poz = doge.first - doge.second, cost = 1; bool foundSimilar = false; while(poz >= 0 && !foundSimilar) { graph[doge.first].push_back(make_pair(poz, cost++)); printf("%d %d %d\n", doge.first, poz, cost - 1); if(doges[poz][doge.second]) foundSimilar = true; poz -= doge.second; } poz = doge.first + doge.second, cost = 1; foundSimilar = false; while(poz < n && !foundSimilar) { graph[doge.first].push_back(make_pair(poz, cost++)); printf("%d %d %d\n", doge.first, poz, cost - 1); if(doges[poz][doge.second]) foundSimilar = true; poz += doge.second; } } printf("%d", dijkstra(n, src, dest)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 1328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1408 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |