제출 #1111601

#제출 시각아이디문제언어결과실행 시간메모리
1111601jmuzhenDrivers (BOI24_drivers)C++14
11 / 100
2076 ms1596 KiB
#include<bits/stdc++.h> using namespace std; #define int long long using ii = pair<int, int>; vector<vector<ii>> adj; int n, m, u; /* observation: abs(dist(a, x) - dist(b, x)) <= dist(a, b) <= dist(a, x) + dist(b, x) * in fact, only the left half is useful. * The answer is YES, iff we can find some abs(dist(a, x) - dist(b, x)) <= p (the query value). */ bool dfs(int u, int t, int p, vector<bool>& visited) { if (visited[u]) return false; if (u == t) return true; visited[u] = true; for (auto [v, w] : adj[u]) { if (w > p) continue; bool r = dfs(v, t, p, visited); if (r) return true; } return false; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> u; // all nodes are 1-indexed. adj = vector<vector<ii>>(n+1, vector<ii>()); for (int i = 0; i < m; i++) { int a, b, t; cin >> a >> b >> t; adj[a].push_back({b, t}); adj[b].push_back({a, t}); } // queries while (u--) { int a, b, p; cin >> a >> b >> p; vector<bool> visited(n+1, false); auto ok = dfs(a, b, p, visited); if (ok) { cout << "TAIP\n"; } else { cout << "NE\n"; } } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool dfs(long long int, long long int, long long int, std::vector<bool>&)':
Main.cpp:21:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   21 |  for (auto [v, w] : adj[u]) {
      |            ^
#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...