Submission #1111569

# Submission time Handle Problem Language Result Execution time Memory
1111569 2024-11-12T09:40:21 Z jmuzhen Drivers (BOI24_drivers) C++17
Compilation error
0 ms 0 KB
#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).
 */
 
 
auto dijkstra(int src) {
	vector<int> dist(n+1, 1e15);
	priority_queue<ii, vector<ii>, greater<ii>> pq;
	
	dist[src] = 0; pq.push({0, src});
	while (!pq.empty()) {
		auto [d, u] = pq.top(); pq.pop();
		if (d > dist[u]) continue;
		for (auto [v, w] : adj[u]) {
			if (dist[u] + w < dist[v]) {
				dist[v] = dist[u] + w;
				pq.push({dist[v], v});
			}
		}	
	}
	return dist;
}

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});
	}
	
	
	// dijkstra
	auto dist = dijkstra(i);
	
	// queries
	while (u--) {
		int a, b, p ; cin >> a >> b >> p;
		const L = abs(dist[a] - dist[b]), R = dist[a] + dist[b];
		bool ok;
		if (p < L) ok = false;
		else if (p >= R) ok = true;
		else {
			int _;
			ok = (_ & 1 == 0);
		}
		
		if (ok) {
			cout << "TAIP\n";
		}
		else {
			cout << "NE\n";
		}
	}

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:23: error: 'i' was not declared in this scope
   50 |  auto dist = dijkstra(i);
      |                       ^
Main.cpp:55:9: error: 'L' does not name a type
   55 |   const L = abs(dist[a] - dist[b]), R = dist[a] + dist[b];
      |         ^
Main.cpp:57:11: error: 'L' was not declared in this scope
   57 |   if (p < L) ok = false;
      |           ^
Main.cpp:58:17: error: 'R' was not declared in this scope
   58 |   else if (p >= R) ok = true;
      |                 ^
Main.cpp:61:16: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   61 |    ok = (_ & 1 == 0);
      |              ~~^~~~