Submission #864528

# Submission time Handle Problem Language Result Execution time Memory
864528 2023-10-23T07:23:04 Z maks007 Toll (BOI17_toll) C++14
0 / 100
3000 ms 194208 KB
// Bismi ALlah
#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main () {
	int n, m, k, query;
	cin >> k >> n >> m >> query;
	vector<pair <int,int>> g[n];
	for(int i = 0; i < m; i ++) {
		int u, v;
		cin >> u >> v;
		int w;
		cin >> w;
		g[u].push_back({v, w});
	}
	map <pair <int,int>,int> dp;
	for(int i = 0; i < n; i ++) {
		dp[{i,i}] = 0;
		for(int j = 0; j < n; j ++) {
			if(dp.count({i, j})) {
				for(auto [u, w] : g[j]) {
					if(dp.count({i, u}) == 0) dp[{i, u}] = dp[{i, j}] + w;
					else dp[{i, u}] = min(dp[{i, u}], dp[{i, j}] + w);
				}
			}
		}
	}
	while(query --) {
		int a, b;
		cin >> a >> b;
		if(dp.count({a, b})) cout << dp[{a, b}] << "\n";
		else cout << -1 << "\n";
	}
	return 0;
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:24:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |     for(auto [u, w] : g[j]) {
      |              ^
# Verdict Execution time Memory Grader output
1 Execution timed out 3061 ms 194208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3074 ms 156564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 66 ms 2176 KB Output is correct
7 Correct 482 ms 31420 KB Output is correct
8 Correct 589 ms 31652 KB Output is correct
9 Correct 466 ms 31580 KB Output is correct
10 Execution timed out 3023 ms 21324 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 66 ms 2176 KB Output is correct
7 Correct 482 ms 31420 KB Output is correct
8 Correct 589 ms 31652 KB Output is correct
9 Correct 466 ms 31580 KB Output is correct
10 Execution timed out 3023 ms 21324 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3061 ms 194208 KB Time limit exceeded
2 Halted 0 ms 0 KB -