# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
526686 | joelau | Autobus (COCI22_autobus) | C++14 | 421 ms | 2068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int N,M,K,Q, lst[75][75], dist[75][5000], inf = 1e9;
priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > pq;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> N >> M;
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) lst[i][j] = i == j ? 0 : inf;
for (int i = 0; i < M; ++i) {
int u,v,w; cin >> u >> v >> w; u--, v--;
lst[u][v] = min(lst[u][v],w);
}
cin >> K >> Q; K = min(K,N-1);
for (int i = 0; i < N; ++i) for (int j = 0; j < N*N; ++j) dist[i][j] = inf;
for (int i = 0; i < N; ++i) {
dist[i][i] = 0;
pq.emplace(0,i);
while (!pq.empty()) {
int d,u; tie(d,u) = pq.top(); pq.pop();
if (d > dist[i][u]) continue;
for (int v = 0; v < N; ++v) if (dist[i][u] + lst[u%N][v] < dist[i][u/N*N+N+v]) {
dist[i][u/N*N+N+v] = dist[i][u] + lst[u%N][v];
pq.emplace(dist[i][u/N*N+N+v],u/N*N+N+v);
}
}
}
while (Q--) {
int u,v; cin >> u >> v; u--, v--;
# | 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... |