Submission #526686

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5266862022-02-16 01:36:14joelauAutobus (COCI22_autobus)C++14
70 / 70
421 ms2068 KiB
#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--;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...