Bare shortest path...
Creating a graph is still subtle... But it doesn't feel fast...
Create a vertex at each time point. Then, we can build a graph in two steps:
(1) I point in time connects a directed edge to the I-1 point in time
(2) If there is a ox [l, r], then l-1 connects an edge to r
The last answer is dis [T].
Think about it and think it's very clever... But it's slow...
1 /************************************** * *********************** 2 Problem: 3389 3 User: rausen 4 Language: C ++ 5 Result: Accepted 6 Time: 652 MS 7 Memory: 33064 kb 8 ************************************* * *************************/9 10 # include <cstdio> 11 # include <algorithm> 12 # include <vector> 13 # include <queue> 14 15 using namespace std; 16 const int inf = (int) 1e9; 17 const int N = 1000005; 18 co Nst int M = N * 2; 19 struct edges {20 int next, to, v; 21} e [M]; 22 struct heap_node {23 int v,; 24} NODE; 25 inline bool operator <(const heap_node & a, const heap_node & B) {26 return. v> B. v; 27} 28 29 int n, d [N], T; 30 int tot, first [N]; 31 bool vis [N]; 32 33 priority_queue View Code(P.s. Orz iwtwiioi is so greedy)
BZOJ3389 [usaco Dec] Cleaning Shifts schedule duty