# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45824 | 2018-04-16T08:30:56 Z | TheDarkning | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 30 ms | 31924 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 ) ); } } } cout << d[ x ]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31608 KB | Output is correct |
2 | Correct | 23 ms | 31720 KB | Output is correct |
3 | Correct | 23 ms | 31720 KB | Output is correct |
4 | Incorrect | 29 ms | 31908 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31908 KB | Output is correct |
2 | Correct | 25 ms | 31908 KB | Output is correct |
3 | Correct | 30 ms | 31908 KB | Output is correct |
4 | Incorrect | 23 ms | 31908 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31908 KB | Output is correct |
2 | Correct | 24 ms | 31908 KB | Output is correct |
3 | Correct | 23 ms | 31908 KB | Output is correct |
4 | Incorrect | 24 ms | 31908 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31908 KB | Output is correct |
2 | Correct | 23 ms | 31908 KB | Output is correct |
3 | Correct | 26 ms | 31924 KB | Output is correct |
4 | Incorrect | 29 ms | 31924 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31924 KB | Output is correct |
2 | Correct | 23 ms | 31924 KB | Output is correct |
3 | Correct | 22 ms | 31924 KB | Output is correct |
4 | Incorrect | 23 ms | 31924 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |