# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
32941 | 2017-10-17T17:15:39 Z | minimario | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 1000 ms | 54564 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; #define f first #define s second const int MAX = 30005; const int SQRT = 90; const int INF = 1000000000; int p[MAX], len[MAX]; // position, length vector<pair<int, int> > g[MAX]; int dist[MAX]; int targ = 0; priority_queue<pair<int, int> > pq; void dijk(int i) { dist[i] = 0; pq.push({0, i}); while (!pq.empty()) { auto top = pq.top(); pq.pop(); int d = -top.f; int loc = top.s; if (loc == targ) { return; } if (d > dist[loc]) { continue; } for (auto i : g[loc]) { int d_new = (d + i.s); if (d_new < dist[i.f]) { dist[i.f] = d_new; pq.push({-d_new, i.f}); } } } } map<int, bool> l[MAX], r[MAX]; int main() { // freopen("a.in", "r", stdin); // freopen("a.out", "w", stdout); int n, m; scanf("%d %d", &n, &m); for (int i=0; i<m; i++) { scanf("%d %d", &p[i], &len[i]); if (!r[p[i]][len[i]]) { for (int j=p[i]+len[i]; j<n; j+=len[i]) { r[j][len[i]] = true; g[p[i]].push_back({j, (j-p[i])/len[i]}); } } if (!l[p[i]][len[i]]) { for (int j=p[i]-len[i]; j>=0; j-=len[i]) { l[j][len[i]] = true; g[p[i]].push_back({j, (p[i]-j)/len[i]}); } } l[p[i]][len[i]] = true; r[p[i]][len[i]] = true; } for (int i=0; i<MAX; i++) { dist[i] = INF; } targ = p[1]; dijk(p[0]); if (dist[p[1]] == INF) { printf("%d\n", -1); } else { printf("%d\n", dist[p[1]]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5892 KB | Output is correct |
2 | Correct | 0 ms | 5892 KB | Output is correct |
3 | Correct | 0 ms | 5892 KB | Output is correct |
4 | Correct | 0 ms | 5892 KB | Output is correct |
5 | Correct | 0 ms | 5892 KB | Output is correct |
6 | Correct | 3 ms | 5892 KB | Output is correct |
7 | Correct | 0 ms | 5892 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5892 KB | Output is correct |
2 | Correct | 0 ms | 5892 KB | Output is correct |
3 | Correct | 0 ms | 5892 KB | Output is correct |
4 | Correct | 3 ms | 5892 KB | Output is correct |
5 | Correct | 0 ms | 5892 KB | Output is correct |
6 | Correct | 0 ms | 5892 KB | Output is correct |
7 | Correct | 0 ms | 5892 KB | Output is correct |
8 | Correct | 0 ms | 5892 KB | Output is correct |
9 | Correct | 0 ms | 5892 KB | Output is correct |
10 | Correct | 0 ms | 6024 KB | Output is correct |
11 | Correct | 3 ms | 6288 KB | Output is correct |
12 | Correct | 0 ms | 5892 KB | Output is correct |
13 | Correct | 0 ms | 5892 KB | Output is correct |
14 | Correct | 3 ms | 6288 KB | Output is correct |
15 | Correct | 3 ms | 6288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5892 KB | Output is correct |
2 | Correct | 0 ms | 5892 KB | Output is correct |
3 | Correct | 0 ms | 5892 KB | Output is correct |
4 | Correct | 0 ms | 5892 KB | Output is correct |
5 | Correct | 0 ms | 5892 KB | Output is correct |
6 | Correct | 0 ms | 5892 KB | Output is correct |
7 | Correct | 3 ms | 5892 KB | Output is correct |
8 | Correct | 0 ms | 5892 KB | Output is correct |
9 | Correct | 3 ms | 5892 KB | Output is correct |
10 | Correct | 0 ms | 6024 KB | Output is correct |
11 | Correct | 3 ms | 6288 KB | Output is correct |
12 | Correct | 0 ms | 5892 KB | Output is correct |
13 | Correct | 0 ms | 5892 KB | Output is correct |
14 | Correct | 3 ms | 6288 KB | Output is correct |
15 | Correct | 6 ms | 6288 KB | Output is correct |
16 | Correct | 3 ms | 6156 KB | Output is correct |
17 | Correct | 6 ms | 6948 KB | Output is correct |
18 | Correct | 0 ms | 6288 KB | Output is correct |
19 | Correct | 3 ms | 6156 KB | Output is correct |
20 | Correct | 3 ms | 6156 KB | Output is correct |
21 | Correct | 0 ms | 6156 KB | Output is correct |
22 | Correct | 0 ms | 6288 KB | Output is correct |
23 | Correct | 3 ms | 6292 KB | Output is correct |
24 | Correct | 3 ms | 6816 KB | Output is correct |
25 | Correct | 3 ms | 6552 KB | Output is correct |
26 | Correct | 3 ms | 6448 KB | Output is correct |
27 | Correct | 3 ms | 6288 KB | Output is correct |
28 | Correct | 6 ms | 7348 KB | Output is correct |
29 | Correct | 26 ms | 9792 KB | Output is correct |
30 | Correct | 6 ms | 7084 KB | Output is correct |
31 | Correct | 13 ms | 8036 KB | Output is correct |
32 | Correct | 9 ms | 7484 KB | Output is correct |
33 | Correct | 59 ms | 13276 KB | Output is correct |
34 | Correct | 46 ms | 13320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5892 KB | Output is correct |
2 | Correct | 3 ms | 5892 KB | Output is correct |
3 | Correct | 0 ms | 5892 KB | Output is correct |
4 | Correct | 0 ms | 5892 KB | Output is correct |
5 | Correct | 0 ms | 5892 KB | Output is correct |
6 | Correct | 3 ms | 5892 KB | Output is correct |
7 | Correct | 3 ms | 5892 KB | Output is correct |
8 | Correct | 0 ms | 5892 KB | Output is correct |
9 | Correct | 0 ms | 5892 KB | Output is correct |
10 | Correct | 0 ms | 6024 KB | Output is correct |
11 | Correct | 3 ms | 6288 KB | Output is correct |
12 | Correct | 0 ms | 5892 KB | Output is correct |
13 | Correct | 0 ms | 5892 KB | Output is correct |
14 | Correct | 3 ms | 6288 KB | Output is correct |
15 | Correct | 0 ms | 6288 KB | Output is correct |
16 | Correct | 3 ms | 6156 KB | Output is correct |
17 | Correct | 3 ms | 6948 KB | Output is correct |
18 | Correct | 3 ms | 6288 KB | Output is correct |
19 | Correct | 0 ms | 6156 KB | Output is correct |
20 | Correct | 0 ms | 6156 KB | Output is correct |
21 | Correct | 3 ms | 6156 KB | Output is correct |
22 | Correct | 0 ms | 6288 KB | Output is correct |
23 | Correct | 0 ms | 6292 KB | Output is correct |
24 | Correct | 3 ms | 6816 KB | Output is correct |
25 | Correct | 3 ms | 6552 KB | Output is correct |
26 | Correct | 0 ms | 6448 KB | Output is correct |
27 | Correct | 0 ms | 6288 KB | Output is correct |
28 | Correct | 3 ms | 7348 KB | Output is correct |
29 | Correct | 13 ms | 9792 KB | Output is correct |
30 | Correct | 3 ms | 7084 KB | Output is correct |
31 | Correct | 13 ms | 8036 KB | Output is correct |
32 | Correct | 9 ms | 7484 KB | Output is correct |
33 | Correct | 69 ms | 13276 KB | Output is correct |
34 | Correct | 39 ms | 13320 KB | Output is correct |
35 | Correct | 69 ms | 13552 KB | Output is correct |
36 | Correct | 3 ms | 7212 KB | Output is correct |
37 | Correct | 136 ms | 18180 KB | Output is correct |
38 | Correct | 139 ms | 17524 KB | Output is correct |
39 | Correct | 136 ms | 17652 KB | Output is correct |
40 | Correct | 159 ms | 17700 KB | Output is correct |
41 | Correct | 136 ms | 17516 KB | Output is correct |
42 | Correct | 9 ms | 6448 KB | Output is correct |
43 | Correct | 6 ms | 6288 KB | Output is correct |
44 | Correct | 13 ms | 6156 KB | Output is correct |
45 | Correct | 496 ms | 35076 KB | Output is correct |
46 | Correct | 516 ms | 35088 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5892 KB | Output is correct |
2 | Correct | 3 ms | 5892 KB | Output is correct |
3 | Correct | 0 ms | 5892 KB | Output is correct |
4 | Correct | 3 ms | 5892 KB | Output is correct |
5 | Correct | 0 ms | 5892 KB | Output is correct |
6 | Correct | 0 ms | 5892 KB | Output is correct |
7 | Correct | 0 ms | 5892 KB | Output is correct |
8 | Correct | 0 ms | 5892 KB | Output is correct |
9 | Correct | 0 ms | 5892 KB | Output is correct |
10 | Correct | 0 ms | 6024 KB | Output is correct |
11 | Correct | 0 ms | 6288 KB | Output is correct |
12 | Correct | 0 ms | 5892 KB | Output is correct |
13 | Correct | 0 ms | 5892 KB | Output is correct |
14 | Correct | 3 ms | 6288 KB | Output is correct |
15 | Correct | 3 ms | 6288 KB | Output is correct |
16 | Correct | 3 ms | 6156 KB | Output is correct |
17 | Correct | 3 ms | 6948 KB | Output is correct |
18 | Correct | 3 ms | 6288 KB | Output is correct |
19 | Correct | 0 ms | 6156 KB | Output is correct |
20 | Correct | 0 ms | 6156 KB | Output is correct |
21 | Correct | 0 ms | 6156 KB | Output is correct |
22 | Correct | 3 ms | 6288 KB | Output is correct |
23 | Correct | 0 ms | 6292 KB | Output is correct |
24 | Correct | 3 ms | 6816 KB | Output is correct |
25 | Correct | 0 ms | 6552 KB | Output is correct |
26 | Correct | 0 ms | 6448 KB | Output is correct |
27 | Correct | 0 ms | 6288 KB | Output is correct |
28 | Correct | 3 ms | 7348 KB | Output is correct |
29 | Correct | 26 ms | 9792 KB | Output is correct |
30 | Correct | 6 ms | 7084 KB | Output is correct |
31 | Correct | 6 ms | 8036 KB | Output is correct |
32 | Correct | 6 ms | 7484 KB | Output is correct |
33 | Correct | 46 ms | 13276 KB | Output is correct |
34 | Correct | 43 ms | 13320 KB | Output is correct |
35 | Correct | 73 ms | 13552 KB | Output is correct |
36 | Correct | 6 ms | 7212 KB | Output is correct |
37 | Correct | 119 ms | 18180 KB | Output is correct |
38 | Correct | 149 ms | 17524 KB | Output is correct |
39 | Correct | 153 ms | 17652 KB | Output is correct |
40 | Correct | 133 ms | 17700 KB | Output is correct |
41 | Correct | 183 ms | 17516 KB | Output is correct |
42 | Correct | 3 ms | 6448 KB | Output is correct |
43 | Correct | 9 ms | 6288 KB | Output is correct |
44 | Correct | 6 ms | 6156 KB | Output is correct |
45 | Correct | 556 ms | 35076 KB | Output is correct |
46 | Correct | 676 ms | 35088 KB | Output is correct |
47 | Execution timed out | 1000 ms | 54564 KB | Execution timed out |
48 | Halted | 0 ms | 0 KB | - |