| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 736277 | Alihan_8 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1 ms | 852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
#define int long long
template <class _T>
bool chmin(_T &x, const _T &y){
bool flag = false;
if ( x > y ){
x = y; flag |= true;
}
return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool flag = false;
if ( x < y ){
x = y; flag |= true;
}
return flag;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m; cin >> n >> m;
vector <int> g[n];
int st, en;
for ( int i = 1; i <= m; i++ ){
int x, y; cin >> x >> y;
g[x].pb(y);
if ( i == 1 ) st = x;
if ( i == 2 ) en = x;
}
const int inf = 1e15 + 1, N = 2e3 + 1;
vector <vector<int>> dis(n, vector <int> (N, inf));
queue <pair<int,int>> q;
for ( auto i: g[st] ){
q.push({st, i});
dis[0][i] = 0;
}
while ( !q.empty() ){
auto [x, p] = q.front();
q.pop();
int v = dis[x][p], y = x, step = 0;
while ( y >= p ){
y -= p; ++step;
if ( chmin(dis[y][p], v + step) ){
q.push({y, p});
}
for ( auto i: g[y] ){
if ( chmin(dis[y][i], v + step) ){
q.push({y, i});
}
}
}
step = 0;
while ( x + p < n ){
x += p; ++step;
if ( chmin(dis[x][p], v + step) ){
q.push({x, p});
}
for ( auto i: g[x] ){
if ( chmin(dis[x][i], v + step) ){
q.push({x, i});
}
}
}
}
int ans = *min_element(all(dis[en]));
if ( ans == inf ) ans = -1;
cout << ans;
cout << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
