# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45826 | 2018-04-16T08:31:43 Z | TheDarkning | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1000 ms | 262144 KB |
/** ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀ <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋> ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟ ♔♕♖♗♘♙ ♚♛♜♝♞♟ ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙ **/ #include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <iomanip> #include <time.h> #include <map> #include <deque> #include <string> #include <memory.h> #include <set> #include <assert.h> #define sz(s) s.size() #define pb push_back #define fr first #define sc second #define mk make_pair #define all(s) s.begin(), s.end() using namespace std; const int N = 2e3 + 5; const int inf = 1e9 + 7; long long n, m, p, b, x, s, cnt, dp[ 2000 ][ 2000 ]; vector < vector < pair < int, int > > > w; main() { scanf("%d%d", &n, &m); w.resize( n + 1 ); for( int i = 1; i <= n; i++ ) w[i].resize( n + 1 ); for( int i = 1; i < 2000; i++ ) for( int j = 1; j < 2000; j++ ) dp[ i ][ j ] = inf; for( int i = 1; i <= m; i++ ) { scanf("%d%d", &p, &b); p++; if( i == 1 ) s = p; if( i == 2 ) x = p; cnt = 0; for( int j = p; j <= n; j += b ) { w[ p ].pb( mk( j, cnt ) ); cnt ++; } cnt = 0; for( int j = p; j > 0; j -= b ) { w[ p ].pb( mk( j, cnt ) ); cnt ++; } } vector < int > d( n + 1, inf ), p( n + 1 ); d[ s ] = 0; set < pair < int, int > > q; q.insert( mk( d[s], s ) ); while( !q.empty() ) { int v = q.begin() -> sc; q.erase( q.begin() ); for( auto x : w[v] ) { int to = x.fr; if( v == to ) continue; if( d[ v ] + x.sc < d[ to ] ) { q.erase( mk( d[ to ], to ) ); d[ to ] = d[ v ] + x.sc; q.insert( mk( d[ to ], to ) ); } } } if( d[ x ] == inf ) d[ x ] = -1; cout << d[ x ]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 31572 KB | Output is correct |
2 | Correct | 23 ms | 31616 KB | Output is correct |
3 | Correct | 22 ms | 31664 KB | Output is correct |
4 | Correct | 23 ms | 31668 KB | Output is correct |
5 | Correct | 23 ms | 31684 KB | Output is correct |
6 | Correct | 26 ms | 31740 KB | Output is correct |
7 | Correct | 24 ms | 31772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 31900 KB | Output is correct |
2 | Correct | 23 ms | 31900 KB | Output is correct |
3 | Correct | 23 ms | 31900 KB | Output is correct |
4 | Correct | 30 ms | 31900 KB | Output is correct |
5 | Correct | 23 ms | 31900 KB | Output is correct |
6 | Correct | 23 ms | 31900 KB | Output is correct |
7 | Correct | 23 ms | 31900 KB | Output is correct |
8 | Correct | 24 ms | 31920 KB | Output is correct |
9 | Correct | 24 ms | 31920 KB | Output is correct |
10 | Correct | 23 ms | 31996 KB | Output is correct |
11 | Correct | 24 ms | 32124 KB | Output is correct |
12 | Correct | 28 ms | 33656 KB | Output is correct |
13 | Correct | 39 ms | 33752 KB | Output is correct |
14 | Correct | 32 ms | 33752 KB | Output is correct |
15 | Correct | 24 ms | 33752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 33752 KB | Output is correct |
2 | Correct | 23 ms | 33752 KB | Output is correct |
3 | Correct | 24 ms | 33752 KB | Output is correct |
4 | Correct | 24 ms | 33752 KB | Output is correct |
5 | Correct | 23 ms | 33752 KB | Output is correct |
6 | Correct | 24 ms | 33752 KB | Output is correct |
7 | Correct | 30 ms | 33752 KB | Output is correct |
8 | Correct | 24 ms | 33752 KB | Output is correct |
9 | Correct | 23 ms | 33752 KB | Output is correct |
10 | Correct | 24 ms | 33752 KB | Output is correct |
11 | Correct | 26 ms | 33752 KB | Output is correct |
12 | Correct | 28 ms | 33772 KB | Output is correct |
13 | Correct | 28 ms | 33772 KB | Output is correct |
14 | Correct | 24 ms | 33772 KB | Output is correct |
15 | Correct | 25 ms | 33772 KB | Output is correct |
16 | Correct | 26 ms | 33772 KB | Output is correct |
17 | Correct | 34 ms | 40336 KB | Output is correct |
18 | Correct | 51 ms | 65428 KB | Output is correct |
19 | Correct | 58 ms | 70928 KB | Output is correct |
20 | Correct | 150 ms | 98432 KB | Output is correct |
21 | Correct | 29 ms | 98432 KB | Output is correct |
22 | Correct | 49 ms | 98432 KB | Output is correct |
23 | Correct | 53 ms | 98432 KB | Output is correct |
24 | Correct | 66 ms | 98432 KB | Output is correct |
25 | Correct | 73 ms | 98432 KB | Output is correct |
26 | Correct | 147 ms | 98432 KB | Output is correct |
27 | Correct | 173 ms | 98432 KB | Output is correct |
28 | Correct | 80 ms | 98432 KB | Output is correct |
29 | Correct | 62 ms | 98432 KB | Output is correct |
30 | Correct | 61 ms | 98432 KB | Output is correct |
31 | Correct | 57 ms | 98432 KB | Output is correct |
32 | Correct | 59 ms | 98432 KB | Output is correct |
33 | Correct | 69 ms | 98432 KB | Output is correct |
34 | Correct | 65 ms | 98432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 98432 KB | Output is correct |
2 | Correct | 25 ms | 98432 KB | Output is correct |
3 | Correct | 23 ms | 98432 KB | Output is correct |
4 | Correct | 24 ms | 98432 KB | Output is correct |
5 | Correct | 26 ms | 98432 KB | Output is correct |
6 | Correct | 23 ms | 98432 KB | Output is correct |
7 | Correct | 24 ms | 98432 KB | Output is correct |
8 | Correct | 23 ms | 98432 KB | Output is correct |
9 | Correct | 24 ms | 98432 KB | Output is correct |
10 | Correct | 24 ms | 98432 KB | Output is correct |
11 | Correct | 25 ms | 98432 KB | Output is correct |
12 | Correct | 27 ms | 98432 KB | Output is correct |
13 | Correct | 28 ms | 98432 KB | Output is correct |
14 | Correct | 24 ms | 98432 KB | Output is correct |
15 | Correct | 25 ms | 98432 KB | Output is correct |
16 | Correct | 25 ms | 98432 KB | Output is correct |
17 | Correct | 42 ms | 98432 KB | Output is correct |
18 | Correct | 51 ms | 98432 KB | Output is correct |
19 | Correct | 55 ms | 98432 KB | Output is correct |
20 | Correct | 142 ms | 98452 KB | Output is correct |
21 | Correct | 26 ms | 98452 KB | Output is correct |
22 | Correct | 50 ms | 98452 KB | Output is correct |
23 | Correct | 53 ms | 98452 KB | Output is correct |
24 | Correct | 67 ms | 98452 KB | Output is correct |
25 | Correct | 72 ms | 98452 KB | Output is correct |
26 | Correct | 145 ms | 98452 KB | Output is correct |
27 | Correct | 140 ms | 98452 KB | Output is correct |
28 | Correct | 78 ms | 98452 KB | Output is correct |
29 | Correct | 62 ms | 98452 KB | Output is correct |
30 | Correct | 60 ms | 98452 KB | Output is correct |
31 | Correct | 58 ms | 98452 KB | Output is correct |
32 | Correct | 59 ms | 98452 KB | Output is correct |
33 | Correct | 64 ms | 98452 KB | Output is correct |
34 | Correct | 64 ms | 98452 KB | Output is correct |
35 | Correct | 68 ms | 98452 KB | Output is correct |
36 | Correct | 56 ms | 98452 KB | Output is correct |
37 | Correct | 124 ms | 98452 KB | Output is correct |
38 | Correct | 111 ms | 98452 KB | Output is correct |
39 | Correct | 96 ms | 98452 KB | Output is correct |
40 | Correct | 94 ms | 98452 KB | Output is correct |
41 | Correct | 96 ms | 98452 KB | Output is correct |
42 | Execution timed out | 1095 ms | 262144 KB | Time limit exceeded |
43 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 262144 KB | Output is correct |
2 | Correct | 23 ms | 262144 KB | Output is correct |
3 | Correct | 24 ms | 262144 KB | Output is correct |
4 | Correct | 24 ms | 262144 KB | Output is correct |
5 | Correct | 23 ms | 262144 KB | Output is correct |
6 | Correct | 24 ms | 262144 KB | Output is correct |
7 | Correct | 23 ms | 262144 KB | Output is correct |
8 | Correct | 23 ms | 262144 KB | Output is correct |
9 | Correct | 24 ms | 262144 KB | Output is correct |
10 | Correct | 26 ms | 262144 KB | Output is correct |
11 | Correct | 24 ms | 262144 KB | Output is correct |
12 | Correct | 28 ms | 262144 KB | Output is correct |
13 | Correct | 28 ms | 262144 KB | Output is correct |
14 | Correct | 24 ms | 262144 KB | Output is correct |
15 | Correct | 24 ms | 262144 KB | Output is correct |
16 | Correct | 25 ms | 262144 KB | Output is correct |
17 | Correct | 33 ms | 262144 KB | Output is correct |
18 | Correct | 60 ms | 262144 KB | Output is correct |
19 | Correct | 54 ms | 262144 KB | Output is correct |
20 | Correct | 140 ms | 262144 KB | Output is correct |
21 | Correct | 27 ms | 262144 KB | Output is correct |
22 | Correct | 52 ms | 262144 KB | Output is correct |
23 | Correct | 56 ms | 262144 KB | Output is correct |
24 | Correct | 75 ms | 262144 KB | Output is correct |
25 | Correct | 74 ms | 262144 KB | Output is correct |
26 | Correct | 162 ms | 262144 KB | Output is correct |
27 | Correct | 139 ms | 262144 KB | Output is correct |
28 | Correct | 99 ms | 262144 KB | Output is correct |
29 | Correct | 80 ms | 262144 KB | Output is correct |
30 | Correct | 58 ms | 262144 KB | Output is correct |
31 | Correct | 57 ms | 262144 KB | Output is correct |
32 | Correct | 61 ms | 262144 KB | Output is correct |
33 | Correct | 74 ms | 262144 KB | Output is correct |
34 | Correct | 77 ms | 262144 KB | Output is correct |
35 | Correct | 65 ms | 262144 KB | Output is correct |
36 | Correct | 42 ms | 262144 KB | Output is correct |
37 | Correct | 93 ms | 262144 KB | Output is correct |
38 | Correct | 97 ms | 262144 KB | Output is correct |
39 | Correct | 104 ms | 262144 KB | Output is correct |
40 | Correct | 99 ms | 262144 KB | Output is correct |
41 | Correct | 116 ms | 262144 KB | Output is correct |
42 | Execution timed out | 1100 ms | 262144 KB | Time limit exceeded |
43 | Halted | 0 ms | 0 KB | - |