답안 #526687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526687 2022-02-16T01:40:06 Z siewjh Autobus (COCI22_autobus) C++17
30 / 70
1000 ms 7444 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1'000'000'007;
int main() {
	int nodes, edges; cin >> nodes >> edges;
	vector<pair<pair<int, int>, int>> edgelist(edges);
	for (int i = 0; i < edges; i++) {
		int a, b, t; cin >> a >> b >> t;
		edgelist[i] = { {a, b},t };
	}
	int maxbus, queries; cin >> maxbus >> queries;
	maxbus = min(maxbus, nodes - 1);
	int dist[71][71][71];
	for (int i = 0; i < 71; i++)
		for (int j = 0; j < 71; j++)
			for (int k = 0; k < 71; k++)
				dist[i][j][k] = inf;
	for (int i = 1; i <= nodes; i++) {
		dist[i][i][0] = 0;
		for (int j = 1; j <= maxbus; j++)
			for (auto e : edgelist) {
				int a = e.first.first, b = e.first.second, t = e.second;
				dist[i][b][j] = min(dist[i][b][j], dist[i][a][j - 1] + t);
			}
	}
	for (int i = 0; i < queries; i++) {
		int a, b; cin >> a >> b;
		int ans = inf;
		for (int j = 0; j <= maxbus; j++) ans = min(ans, dist[a][b][j]);
		cout << ((ans == inf) ? -1 : ans) << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 1 ms 1612 KB Output is correct
4 Correct 1 ms 1612 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 1 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1704 KB Output is correct
2 Correct 10 ms 1612 KB Output is correct
3 Correct 9 ms 1612 KB Output is correct
4 Correct 10 ms 1612 KB Output is correct
5 Correct 11 ms 1712 KB Output is correct
6 Correct 15 ms 1768 KB Output is correct
7 Correct 19 ms 1756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 1 ms 1612 KB Output is correct
4 Correct 1 ms 1612 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 1 ms 1612 KB Output is correct
7 Correct 14 ms 1728 KB Output is correct
8 Correct 21 ms 1612 KB Output is correct
9 Correct 13 ms 1700 KB Output is correct
10 Correct 30 ms 1700 KB Output is correct
11 Correct 39 ms 1740 KB Output is correct
12 Correct 103 ms 1740 KB Output is correct
13 Execution timed out 1042 ms 7444 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1612 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 1 ms 1612 KB Output is correct
4 Correct 1 ms 1612 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 1 ms 1612 KB Output is correct
7 Correct 9 ms 1704 KB Output is correct
8 Correct 10 ms 1612 KB Output is correct
9 Correct 9 ms 1612 KB Output is correct
10 Correct 10 ms 1612 KB Output is correct
11 Correct 11 ms 1712 KB Output is correct
12 Correct 15 ms 1768 KB Output is correct
13 Correct 19 ms 1756 KB Output is correct
14 Correct 14 ms 1728 KB Output is correct
15 Correct 21 ms 1612 KB Output is correct
16 Correct 13 ms 1700 KB Output is correct
17 Correct 30 ms 1700 KB Output is correct
18 Correct 39 ms 1740 KB Output is correct
19 Correct 103 ms 1740 KB Output is correct
20 Execution timed out 1042 ms 7444 KB Time limit exceeded
21 Halted 0 ms 0 KB -