제출 #1111560

#제출 시각아이디문제언어결과실행 시간메모리
1111560YSH2020Drivers (BOI24_drivers)C++17
0 / 100
2093 ms392772 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m, u; cin >> n >> m >> u; vector <vector<pair<int, int>>> edges; vector<pair<int, int>> empty; for (int i= 0; i < n+5; i++) edges.push_back(empty); for (int i = 0; i < m; i++) { int x, y, z; cin >> x >> y >> z; edges[x].push_back({y, z}); edges[y].push_back({x, z}); } int ans[n+5][n+5]; for (int i = 1; i <= n; i++) { //dijkstra from here? for (int j =1; j <= n; j++) ans[i][j] = 1000000500; ans[i][i] = 0; priority_queue <pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; pq.push({0, i}); while (pq.size() > 0) { auto tmp = pq.top(); pq.pop(); if (tmp.first > ans[i][tmp.second]) continue; ans[i][tmp.second] = tmp.first; for (auto k:edges[tmp.second]) { if (max(tmp.first, k.second) < ans[i][k.first]) {ans[i][k.first] = max(tmp.first, k.second); pq.push({max(tmp.first, k.second), k.first});} } } } while (u--) { int x, y, z; cin >> x >> y >> z; if (ans[x][y] > z) cout << "NE" << '\n'; else cout << "TAIP" << '\n'; } }
#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...