# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
648437 |
2022-10-06T13:32:17 Z |
ymm |
Toll (BOI17_toll) |
C++17 |
|
2723 ms |
2788 KB |
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
typedef unsigned int vec __attribute__((vector_size(32), aligned(4)));
const int N = 50'016;
const unsigned int two31 = 1u<<31;
vec toll[N];
unsigned int dis[N];
int n, m, k, o;
#define SMIN(x, y) ((x)=(x)<(y)?(x):(y))
int order(int v, int u)
{
const int k = ::k;
fill(dis+v, dis+u+1, (1u<<31)-1);
dis[v] = 0;
while (v%k) {
SMIN(*(vec *)(dis + v+k-v%k),
(dis[v] + toll[v]) | (toll[v]&two31));
++v;
}
const int vk = v/k; // vulkan
const int uk = u/k; // united kingdom
Loop (i,vk,uk) {
const int ki = i*k;
Loop (x,0,k) {
SMIN(*(vec *)(dis+ki+k),
(dis[ki+x] + toll[ki+x]) | (toll[ki+x]&two31));
}
}
return dis[u] == (1u<<31)-1? -1: dis[u];
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
fill(toll, toll+N, vec{~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u});
cin >> k >> n >> m >> o;
Loop (i,0,m) {
int v, u, w;
cin >> v >> u >> w;
toll[v][u%k] = w;
}
while (o--) {
int v, u;
cin >> v >> u;
cout << order(v, u) << '\n';
};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1749 ms |
2728 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
5 ms |
1876 KB |
Output is correct |
6 |
Correct |
6 ms |
1876 KB |
Output is correct |
7 |
Correct |
6 ms |
1904 KB |
Output is correct |
8 |
Correct |
1788 ms |
2464 KB |
Output is correct |
9 |
Correct |
1706 ms |
2400 KB |
Output is correct |
10 |
Correct |
1757 ms |
2332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1393 ms |
2348 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
57 ms |
1976 KB |
Output is correct |
8 |
Correct |
31 ms |
1968 KB |
Output is correct |
9 |
Correct |
2723 ms |
2448 KB |
Output is correct |
10 |
Correct |
1219 ms |
2732 KB |
Output is correct |
11 |
Correct |
1489 ms |
2664 KB |
Output is correct |
12 |
Correct |
1236 ms |
2604 KB |
Output is correct |
13 |
Correct |
182 ms |
2524 KB |
Output is correct |
14 |
Correct |
243 ms |
2532 KB |
Output is correct |
15 |
Correct |
172 ms |
2528 KB |
Output is correct |
16 |
Correct |
177 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1892 KB |
Output is correct |
3 |
Correct |
1 ms |
1892 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
2 ms |
1876 KB |
Output is correct |
7 |
Correct |
2 ms |
1908 KB |
Output is correct |
8 |
Correct |
3 ms |
1876 KB |
Output is correct |
9 |
Correct |
2 ms |
1876 KB |
Output is correct |
10 |
Correct |
41 ms |
2512 KB |
Output is correct |
11 |
Correct |
44 ms |
2568 KB |
Output is correct |
12 |
Correct |
51 ms |
2580 KB |
Output is correct |
13 |
Correct |
52 ms |
2508 KB |
Output is correct |
14 |
Correct |
41 ms |
2528 KB |
Output is correct |
15 |
Correct |
26 ms |
2400 KB |
Output is correct |
16 |
Correct |
27 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1892 KB |
Output is correct |
3 |
Correct |
1 ms |
1892 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
2 ms |
1876 KB |
Output is correct |
7 |
Correct |
2 ms |
1908 KB |
Output is correct |
8 |
Correct |
3 ms |
1876 KB |
Output is correct |
9 |
Correct |
2 ms |
1876 KB |
Output is correct |
10 |
Correct |
41 ms |
2512 KB |
Output is correct |
11 |
Correct |
44 ms |
2568 KB |
Output is correct |
12 |
Correct |
51 ms |
2580 KB |
Output is correct |
13 |
Correct |
52 ms |
2508 KB |
Output is correct |
14 |
Correct |
41 ms |
2528 KB |
Output is correct |
15 |
Correct |
26 ms |
2400 KB |
Output is correct |
16 |
Correct |
27 ms |
2384 KB |
Output is correct |
17 |
Correct |
339 ms |
2592 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
2 ms |
1876 KB |
Output is correct |
20 |
Correct |
1 ms |
1896 KB |
Output is correct |
21 |
Correct |
1 ms |
1876 KB |
Output is correct |
22 |
Correct |
2 ms |
1888 KB |
Output is correct |
23 |
Correct |
15 ms |
1932 KB |
Output is correct |
24 |
Correct |
8 ms |
1904 KB |
Output is correct |
25 |
Correct |
6 ms |
1876 KB |
Output is correct |
26 |
Correct |
5 ms |
1876 KB |
Output is correct |
27 |
Correct |
578 ms |
2584 KB |
Output is correct |
28 |
Correct |
286 ms |
2600 KB |
Output is correct |
29 |
Correct |
314 ms |
2596 KB |
Output is correct |
30 |
Correct |
296 ms |
2588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1749 ms |
2728 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
5 ms |
1876 KB |
Output is correct |
6 |
Correct |
6 ms |
1876 KB |
Output is correct |
7 |
Correct |
6 ms |
1904 KB |
Output is correct |
8 |
Correct |
1788 ms |
2464 KB |
Output is correct |
9 |
Correct |
1706 ms |
2400 KB |
Output is correct |
10 |
Correct |
1757 ms |
2332 KB |
Output is correct |
11 |
Correct |
1393 ms |
2348 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1876 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
57 ms |
1976 KB |
Output is correct |
18 |
Correct |
31 ms |
1968 KB |
Output is correct |
19 |
Correct |
2723 ms |
2448 KB |
Output is correct |
20 |
Correct |
1219 ms |
2732 KB |
Output is correct |
21 |
Correct |
1489 ms |
2664 KB |
Output is correct |
22 |
Correct |
1236 ms |
2604 KB |
Output is correct |
23 |
Correct |
182 ms |
2524 KB |
Output is correct |
24 |
Correct |
243 ms |
2532 KB |
Output is correct |
25 |
Correct |
172 ms |
2528 KB |
Output is correct |
26 |
Correct |
177 ms |
2516 KB |
Output is correct |
27 |
Correct |
1 ms |
1876 KB |
Output is correct |
28 |
Correct |
1 ms |
1892 KB |
Output is correct |
29 |
Correct |
1 ms |
1892 KB |
Output is correct |
30 |
Correct |
1 ms |
1876 KB |
Output is correct |
31 |
Correct |
2 ms |
1876 KB |
Output is correct |
32 |
Correct |
2 ms |
1876 KB |
Output is correct |
33 |
Correct |
2 ms |
1908 KB |
Output is correct |
34 |
Correct |
3 ms |
1876 KB |
Output is correct |
35 |
Correct |
2 ms |
1876 KB |
Output is correct |
36 |
Correct |
41 ms |
2512 KB |
Output is correct |
37 |
Correct |
44 ms |
2568 KB |
Output is correct |
38 |
Correct |
51 ms |
2580 KB |
Output is correct |
39 |
Correct |
52 ms |
2508 KB |
Output is correct |
40 |
Correct |
41 ms |
2528 KB |
Output is correct |
41 |
Correct |
26 ms |
2400 KB |
Output is correct |
42 |
Correct |
27 ms |
2384 KB |
Output is correct |
43 |
Correct |
339 ms |
2592 KB |
Output is correct |
44 |
Correct |
1 ms |
1876 KB |
Output is correct |
45 |
Correct |
2 ms |
1876 KB |
Output is correct |
46 |
Correct |
1 ms |
1896 KB |
Output is correct |
47 |
Correct |
1 ms |
1876 KB |
Output is correct |
48 |
Correct |
2 ms |
1888 KB |
Output is correct |
49 |
Correct |
15 ms |
1932 KB |
Output is correct |
50 |
Correct |
8 ms |
1904 KB |
Output is correct |
51 |
Correct |
6 ms |
1876 KB |
Output is correct |
52 |
Correct |
5 ms |
1876 KB |
Output is correct |
53 |
Correct |
578 ms |
2584 KB |
Output is correct |
54 |
Correct |
286 ms |
2600 KB |
Output is correct |
55 |
Correct |
314 ms |
2596 KB |
Output is correct |
56 |
Correct |
296 ms |
2588 KB |
Output is correct |
57 |
Correct |
472 ms |
2648 KB |
Output is correct |
58 |
Correct |
1953 ms |
2688 KB |
Output is correct |
59 |
Correct |
1035 ms |
2788 KB |
Output is correct |