# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41509 | 2018-02-17T15:30:48 Z | fest | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 1000 ms | 10324 KB |
// fest #include <bits/stdc++.h> #define pb push_back #define F first #define S second #define y1 dasdasfasfas #define x1 wqdadfasfasfas #define All(c) c.begin(), c.end() #define SZ(A) (int((A).size())) #define umap unordered_map #define FILENAME "" #define __ fflush(stdout) typedef long long ll; typedef long double ld; using namespace std; void FREOPEN() { #ifdef COMP freopen(".in", "r", stdin); freopen("1.out", "w", stdout); #else freopen(FILENAME".in", "r", stdin); freopen(FILENAME".out", "w", stdout); #endif } inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; } const int N = 30500, inf = 1e9 * 2, MOD = (int)1e9 + 7; char CH[N]; const ll INF = 1e18; const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1}; const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1}; int dp[N]; vector<int> have[N]; umap<int, bool> was[N]; int main() { int n, m; scanf("%d %d", &n, &m); int start = 0, finish = 0; for (int i = 0; i < m; i++) { int b, p; scanf("%d %d", &b, &p); have[b].pb(p); was[b][p] = 1; if (i == 0) start = b; if (i == 1) finish = b; } for (int i = 0; i < n; i++) sort(All(have[i])); for (int i = 0; i < n; i++) dp[i] = inf; dp[start] = 0; set<pair<int, int> > s; s.insert({0, start}); while (!s.empty()) { int v = s.begin() -> S; s.erase(s.begin()); for (auto p : have[v]) { for (int mul = 1; v + mul * p < n; mul++) { int u = v + mul * p; if (dp[u] > dp[v] + mul) { s.erase({dp[u], u}); dp[u] = dp[v] + mul; s.insert({dp[u], u}); } if (was[u][p]) break; } for (int mul = 1; v - mul * p >= 0; mul++) { int u = v - mul * p; if (dp[u] > dp[v] + mul) { s.erase({dp[u], u}); dp[u] = dp[v] + mul; s.insert({dp[u], u}); } if (was[u][p]) break; } } } if (dp[finish] == inf) dp[finish] = -1; cout << dp[finish]; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2684 KB | Output is correct |
2 | Correct | 4 ms | 2784 KB | Output is correct |
3 | Correct | 3 ms | 2784 KB | Output is correct |
4 | Correct | 4 ms | 2860 KB | Output is correct |
5 | Correct | 3 ms | 2904 KB | Output is correct |
6 | Correct | 4 ms | 3000 KB | Output is correct |
7 | Correct | 3 ms | 3000 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3012 KB | Output is correct |
2 | Correct | 4 ms | 3012 KB | Output is correct |
3 | Correct | 3 ms | 3012 KB | Output is correct |
4 | Correct | 3 ms | 3012 KB | Output is correct |
5 | Correct | 4 ms | 3012 KB | Output is correct |
6 | Correct | 4 ms | 3012 KB | Output is correct |
7 | Correct | 3 ms | 3012 KB | Output is correct |
8 | Correct | 3 ms | 3012 KB | Output is correct |
9 | Correct | 4 ms | 3012 KB | Output is correct |
10 | Correct | 5 ms | 3048 KB | Output is correct |
11 | Correct | 5 ms | 3176 KB | Output is correct |
12 | Correct | 7 ms | 3176 KB | Output is correct |
13 | Correct | 4 ms | 3176 KB | Output is correct |
14 | Correct | 5 ms | 3176 KB | Output is correct |
15 | Correct | 5 ms | 3176 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3176 KB | Output is correct |
2 | Correct | 3 ms | 3176 KB | Output is correct |
3 | Correct | 4 ms | 3176 KB | Output is correct |
4 | Correct | 3 ms | 3176 KB | Output is correct |
5 | Correct | 3 ms | 3176 KB | Output is correct |
6 | Correct | 3 ms | 3176 KB | Output is correct |
7 | Correct | 4 ms | 3176 KB | Output is correct |
8 | Correct | 4 ms | 3176 KB | Output is correct |
9 | Correct | 3 ms | 3176 KB | Output is correct |
10 | Correct | 5 ms | 3176 KB | Output is correct |
11 | Correct | 5 ms | 3180 KB | Output is correct |
12 | Correct | 7 ms | 3180 KB | Output is correct |
13 | Correct | 4 ms | 3180 KB | Output is correct |
14 | Correct | 5 ms | 3180 KB | Output is correct |
15 | Correct | 5 ms | 3180 KB | Output is correct |
16 | Correct | 4 ms | 3180 KB | Output is correct |
17 | Correct | 7 ms | 3568 KB | Output is correct |
18 | Correct | 5 ms | 3568 KB | Output is correct |
19 | Correct | 3 ms | 3568 KB | Output is correct |
20 | Correct | 5 ms | 3568 KB | Output is correct |
21 | Correct | 4 ms | 3568 KB | Output is correct |
22 | Correct | 4 ms | 3568 KB | Output is correct |
23 | Correct | 6 ms | 3568 KB | Output is correct |
24 | Correct | 8 ms | 3568 KB | Output is correct |
25 | Correct | 6 ms | 3568 KB | Output is correct |
26 | Correct | 88 ms | 3568 KB | Output is correct |
27 | Correct | 80 ms | 3568 KB | Output is correct |
28 | Correct | 9 ms | 4076 KB | Output is correct |
29 | Correct | 22 ms | 5740 KB | Output is correct |
30 | Correct | 8 ms | 5740 KB | Output is correct |
31 | Correct | 14 ms | 5740 KB | Output is correct |
32 | Correct | 10 ms | 5740 KB | Output is correct |
33 | Correct | 41 ms | 8300 KB | Output is correct |
34 | Correct | 45 ms | 8300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 8300 KB | Output is correct |
2 | Correct | 3 ms | 8300 KB | Output is correct |
3 | Correct | 3 ms | 8300 KB | Output is correct |
4 | Correct | 3 ms | 8300 KB | Output is correct |
5 | Correct | 3 ms | 8300 KB | Output is correct |
6 | Correct | 3 ms | 8300 KB | Output is correct |
7 | Correct | 4 ms | 8300 KB | Output is correct |
8 | Correct | 3 ms | 8300 KB | Output is correct |
9 | Correct | 3 ms | 8300 KB | Output is correct |
10 | Correct | 4 ms | 8300 KB | Output is correct |
11 | Correct | 5 ms | 8300 KB | Output is correct |
12 | Correct | 7 ms | 8300 KB | Output is correct |
13 | Correct | 4 ms | 8300 KB | Output is correct |
14 | Correct | 5 ms | 8300 KB | Output is correct |
15 | Correct | 9 ms | 8300 KB | Output is correct |
16 | Correct | 4 ms | 8300 KB | Output is correct |
17 | Correct | 8 ms | 8300 KB | Output is correct |
18 | Correct | 4 ms | 8300 KB | Output is correct |
19 | Correct | 4 ms | 8300 KB | Output is correct |
20 | Correct | 4 ms | 8300 KB | Output is correct |
21 | Correct | 4 ms | 8300 KB | Output is correct |
22 | Correct | 4 ms | 8300 KB | Output is correct |
23 | Correct | 6 ms | 8300 KB | Output is correct |
24 | Correct | 8 ms | 8300 KB | Output is correct |
25 | Correct | 7 ms | 8300 KB | Output is correct |
26 | Correct | 79 ms | 8300 KB | Output is correct |
27 | Correct | 71 ms | 8300 KB | Output is correct |
28 | Correct | 9 ms | 8300 KB | Output is correct |
29 | Correct | 20 ms | 8300 KB | Output is correct |
30 | Correct | 8 ms | 8300 KB | Output is correct |
31 | Correct | 12 ms | 8300 KB | Output is correct |
32 | Correct | 11 ms | 8300 KB | Output is correct |
33 | Correct | 38 ms | 8300 KB | Output is correct |
34 | Correct | 40 ms | 8312 KB | Output is correct |
35 | Correct | 36 ms | 8312 KB | Output is correct |
36 | Correct | 9 ms | 8312 KB | Output is correct |
37 | Correct | 56 ms | 10324 KB | Output is correct |
38 | Correct | 60 ms | 10324 KB | Output is correct |
39 | Correct | 62 ms | 10324 KB | Output is correct |
40 | Correct | 55 ms | 10324 KB | Output is correct |
41 | Correct | 58 ms | 10324 KB | Output is correct |
42 | Execution timed out | 1060 ms | 10324 KB | Time limit exceeded |
43 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 10324 KB | Output is correct |
2 | Correct | 4 ms | 10324 KB | Output is correct |
3 | Correct | 3 ms | 10324 KB | Output is correct |
4 | Correct | 3 ms | 10324 KB | Output is correct |
5 | Correct | 3 ms | 10324 KB | Output is correct |
6 | Correct | 3 ms | 10324 KB | Output is correct |
7 | Correct | 3 ms | 10324 KB | Output is correct |
8 | Correct | 3 ms | 10324 KB | Output is correct |
9 | Correct | 3 ms | 10324 KB | Output is correct |
10 | Correct | 4 ms | 10324 KB | Output is correct |
11 | Correct | 6 ms | 10324 KB | Output is correct |
12 | Correct | 7 ms | 10324 KB | Output is correct |
13 | Correct | 4 ms | 10324 KB | Output is correct |
14 | Correct | 5 ms | 10324 KB | Output is correct |
15 | Correct | 7 ms | 10324 KB | Output is correct |
16 | Correct | 4 ms | 10324 KB | Output is correct |
17 | Correct | 10 ms | 10324 KB | Output is correct |
18 | Correct | 5 ms | 10324 KB | Output is correct |
19 | Correct | 4 ms | 10324 KB | Output is correct |
20 | Correct | 5 ms | 10324 KB | Output is correct |
21 | Correct | 4 ms | 10324 KB | Output is correct |
22 | Correct | 4 ms | 10324 KB | Output is correct |
23 | Correct | 7 ms | 10324 KB | Output is correct |
24 | Correct | 9 ms | 10324 KB | Output is correct |
25 | Correct | 7 ms | 10324 KB | Output is correct |
26 | Correct | 78 ms | 10324 KB | Output is correct |
27 | Correct | 75 ms | 10324 KB | Output is correct |
28 | Correct | 10 ms | 10324 KB | Output is correct |
29 | Correct | 20 ms | 10324 KB | Output is correct |
30 | Correct | 8 ms | 10324 KB | Output is correct |
31 | Correct | 12 ms | 10324 KB | Output is correct |
32 | Correct | 11 ms | 10324 KB | Output is correct |
33 | Correct | 46 ms | 10324 KB | Output is correct |
34 | Correct | 52 ms | 10324 KB | Output is correct |
35 | Correct | 38 ms | 10324 KB | Output is correct |
36 | Correct | 10 ms | 10324 KB | Output is correct |
37 | Correct | 56 ms | 10324 KB | Output is correct |
38 | Correct | 79 ms | 10324 KB | Output is correct |
39 | Correct | 110 ms | 10324 KB | Output is correct |
40 | Correct | 65 ms | 10324 KB | Output is correct |
41 | Correct | 76 ms | 10324 KB | Output is correct |
42 | Execution timed out | 1064 ms | 10324 KB | Time limit exceeded |
43 | Halted | 0 ms | 0 KB | - |