제출 #628811

#제출 시각아이디문제언어결과실행 시간메모리
628811a_aguiloToll (BOI17_toll)C++14
0 / 100
886 ms524288 KiB
#include<bits/stdc++.h> using namespace std; void apsp(vector<vector<int>> & matrizAdyacencia) { int N = (int) matrizAdyacencia.size(); for (int k = 0; k < N; k++){ for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++) matrizAdyacencia[i][j] = min(matrizAdyacencia[i][j], matrizAdyacencia[i][k] + matrizAdyacencia[k][j]); } } } int main(){ int K, N, M, O, t, a, b; cin >> K >> N >> M >> O; vector<vector<int>> G(N, vector<int>(N, 1e9+7)); for(int i = 0; i < N; ++i)G[i][i] = 0; for(int i = 0; i < M; ++i){ cin >> a >> b >> t; G[a][b] = t; } apsp(G); while(O--){ cin >> a >> b; if(G[a][b] == 1e9+7) cout << -1 << endl; else cout << G[a][b]<< endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...