# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938636 |
2024-03-05T11:35:04 Z |
faruk |
Toll (BOI17_toll) |
C++17 |
|
3000 ms |
4408 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, k, q;
cin >> k >> n >> m >> q;
vector<vector<pii> > graph(n + k);
for (int i = 0; i < m; i++) {
int f, t, p;
cin >>f >> t >> p;
graph[f].push_back(pii(t % k, p));
}
while (q--) {
int f, t;
cin >> f >> t;
int SF = f / k, ST = t / k;
vector<ll> ans(k, 1e18);
ans[f % k] = 0;
for (int i = SF; i < ST; i++) {
vector<ll> neww(k, 1e18);
for (int j = 0; j < 5; j++)
for (auto &[to, w] : graph[i * k + j])
neww[to] = min(neww[to], ans[j] + w);
ans = neww;
}
if (ans[t % k] == 1e18)
cout << "-1\n";
else
cout << ans[t % k] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3024 ms |
3160 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3035 ms |
4408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3024 ms |
3160 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |