| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1361331 | biserailieva | Circle Passing (EGOI24_circlepassing) | C++20 | 2093 ms | 1114112 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, q;
cin >> n >> m >> q;
int N = 2 * n;
vector<int> tele;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
tele.push_back(k);
tele.push_back(k + n);
}
while (q--) {
int x, y;
cin >> x >> y;
vector<int> dist(N, -1);
queue<int> qu;
dist[x] = 0;
qu.push(x);
bool usedTeleport = false;
while (!qu.empty()) {
int v = qu.front(); qu.pop();
if (v == y) break;
int l = (v - 1 + N) % N;
int r = (v + 1) % N;
if (dist[l] == -1) {
dist[l] = dist[v] + 1;
qu.push(l);
}
if (dist[r] == -1) {
dist[r] = dist[v] + 1;
qu.push(r);
}
if (!usedTeleport) {
usedTeleport = true;
for (int u : tele) {
if (dist[u] == -1) {
dist[u] = dist[v] + 1;
qu.push(u);
}
}
}
}
cout << dist[y] << '\n';
}
return 0;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
