# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
718078 |
2023-04-03T09:44:19 Z |
Johann |
Toll (BOI17_toll) |
C++14 |
|
3000 ms |
7856 KB |
// Gets sub1-sub4 with more or less naive approach
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define vb vector<bool>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vpii>
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define F0R(i,n) for (int i = 0; i < (n); ++i)
const int MAXN = 50005;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int k,n,m,o;
cin >> k >> n >> m >> o;
vvpii adj(n);
F0R(i,m) {
int a,b,t;
cin >> a >> b >> t;
adj[a].push_back({b,t});
}
vi ans(o, -1);
vvpii orders(n);
F0R(i,o) {
int a,b;
cin >> a >> b;
if (a <= b)
orders[a].push_back({ b, i });
}
F0R(i,n) { sort(all(orders[i])); reverse(all(orders[i])); }
F0R(a,n) {
int first = a;
vi buffer(2*k+1, INT_MAX);
buffer[0] = 0;
while (sz(orders[a]) > 0) {
if (first == orders[a].back().first) {
ans[orders[a].back().second] = (buffer[0] == INT_MAX) ? -1 : buffer[0];
orders[a].pop_back();
} else {
if (buffer[0] != INT_MAX) {
for (pii e : adj[first]) {
auto [u, t] = e;
buffer[u - first] = min(buffer[u-first], buffer[0] + t);
}
}
for (int i = 0; i < sz(buffer)-1; ++i) swap(buffer[i], buffer[i+1]);
buffer.back() = INT_MAX;
++first;
}
}
}
for (int x : ans) cout << x << "\n";
}
Compilation message
toll.cpp: In function 'int main()':
toll.cpp:51:30: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
51 | auto [u, t] = e;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
5456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
6116 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
4 ms |
724 KB |
Output is correct |
8 |
Correct |
4 ms |
724 KB |
Output is correct |
9 |
Correct |
20 ms |
5380 KB |
Output is correct |
10 |
Correct |
49 ms |
7628 KB |
Output is correct |
11 |
Correct |
39 ms |
6140 KB |
Output is correct |
12 |
Correct |
32 ms |
5656 KB |
Output is correct |
13 |
Correct |
52 ms |
7108 KB |
Output is correct |
14 |
Correct |
34 ms |
4940 KB |
Output is correct |
15 |
Correct |
26 ms |
4300 KB |
Output is correct |
16 |
Correct |
27 ms |
4248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
26 ms |
5084 KB |
Output is correct |
11 |
Correct |
77 ms |
5868 KB |
Output is correct |
12 |
Correct |
98 ms |
7268 KB |
Output is correct |
13 |
Correct |
129 ms |
7828 KB |
Output is correct |
14 |
Correct |
90 ms |
6532 KB |
Output is correct |
15 |
Correct |
51 ms |
4092 KB |
Output is correct |
16 |
Correct |
45 ms |
4096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
328 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
26 ms |
5084 KB |
Output is correct |
11 |
Correct |
77 ms |
5868 KB |
Output is correct |
12 |
Correct |
98 ms |
7268 KB |
Output is correct |
13 |
Correct |
129 ms |
7828 KB |
Output is correct |
14 |
Correct |
90 ms |
6532 KB |
Output is correct |
15 |
Correct |
51 ms |
4092 KB |
Output is correct |
16 |
Correct |
45 ms |
4096 KB |
Output is correct |
17 |
Correct |
1101 ms |
5888 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
3 ms |
468 KB |
Output is correct |
24 |
Correct |
6 ms |
468 KB |
Output is correct |
25 |
Correct |
11 ms |
468 KB |
Output is correct |
26 |
Correct |
11 ms |
596 KB |
Output is correct |
27 |
Correct |
166 ms |
5168 KB |
Output is correct |
28 |
Correct |
1448 ms |
7356 KB |
Output is correct |
29 |
Correct |
1594 ms |
7856 KB |
Output is correct |
30 |
Correct |
976 ms |
6592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3043 ms |
5456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |