# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
699346 | nguyentunglam | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 254 ms | 112396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 3e4 + 10, M = 1e9;
bitset<M> dd;
vector<int> lst[N];
int cnt;
bool mark[N];
bool id(int x, int y) {
int code = x * (3e4 + 1) + y;
if (dd[code]) return 1;
dd[code] = 1;
return 0;
}
int main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen ("task.inp", "r")) {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
}
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int n, m; cin >> n >> m;
pair<int, int> st, ed;
for(int i = 0; i < m; i++) {
int b, p; cin >> b >> p;
lst[b].push_back(p);
if (i == 0) st = make_pair(b, p);
if (i == 1) ed = make_pair(b, p);
}
deque<tuple<int, int, int> > dq;
id(st.fi, st.se);
dq.push_back({0, st.fi, st.se});
while (!dq.empty()) {
auto [cost, pos, jump] = dq.front(); dq.pop_front();
if (pos == ed.fi) return cout << cost, 0;
if (!mark[pos]) {
for(auto &j : lst[pos]) {
if (!id(pos, j)) dq.push_front({cost, pos, j});
}
mark[pos] = 1;
}
if (pos + jump < n) {
if (!id(pos + jump, jump)) dq.push_back({cost + 1, pos + jump, jump});
}
if (pos - jump >= 0) {
if (!id(pos - jump, jump)) dq.push_back({cost + 1, pos - jump, jump});
}
}
cout << -1;
}
컴파일 시 표준 에러 (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... |