luogu#P4990. 小埋与刺客传奇

小埋与刺客传奇

Background

The testdata has been updated.

After several days and nights of intense grinding, Umaru finally reached the last level, the boss level of DancingDancing LineLineTheThe LegendLegend ofof AssassinAssassin.

avatar

avatar

Problem Description

As shown in the figure, the boss level often has broken roads and sudden obstacles.

Umaru is troubled because she does not know the complete map. So she made many attempts and summarized the roads that appear or disappear over time, and her position at those moments. To simplify the problem, we assume that Umaru's position never changes.

Now she wants to know: from what earliest moment can she see a path that can lead to the destination. Also, because there are diamonds on some paths and these diamonds can give extra points, Umaru also wants to know the maximum score she can obtain by going to the destination following the current map at the earliest moment when she can first see a path to the destination.

Input Format

The first line contains two integers nn and mm, representing the number of nodes in the map and the number of initial edges. Nodes are numbered from 1n1-n. Initially, this is time 00. Umaru is at node 11, and the destination is always node nn.

The next mm lines each contain three integers uiu_i, viv_i, wiw_i, describing an edge from uiu_i to viv_i with score wiw_i.

The next line contains one integer tt, representing the number of moments when a new edge appears or an old edge disappears. If no edge appears or disappears, then t=0t=0.

The next tt lines describe events. In each line, the first number is tmjtm_j, the time when this event happens. The second number is typetype:

  • If type==0type==0, it means a new edge appears. Then three numbers uju_j, vjv_j, wjw_j follow, describing the edge (same meaning as above).
  • If type==1type==1, then one number kk follows, meaning that at the current time, the kk-th road among those that have not disappeared disappears.

Output Format

If at no time it is possible to reach the destination, output "ContinueContinue fromfrom thethe lastlast checkpointcheckpoint". Otherwise, output two lines:

  • The first line contains one number tmptmp, the minimum time when a path to the destination can be seen.
  • The second line contains one number scorescore, the maximum score that can be obtained when reaching the destination at that time.
3 3
1 2 1
2 3 1
1 3 1
0
0
2
3 3
1 2 1
2 2 0
3 1 1
0
Continue from the last checkpoint
3 3
1 2 1
2 2 0
3 1 1
4
2 0 1 3 1
1 1 3
3 1 1
5 1 1
2
1

Hint

This problem has 1010 test points. The detailed information is as follows.

11: n<=100000n<=100000, m<=200000m<=200000, t<=100000t<=100000. Output "ContinueContinue fromfrom thethe lastlast checkpointcheckpoint". Score: 55.

22: n<=100n<=100, m<=10000m<=10000, t<=100t<=100. No special properties. Score: 1010.

33: n<=100000n<=100000, m<=200000m<=200000, t<=100000t<=100000. All edges have score 00. Score: 1010.

44: n<=100000n<=100000, m<=200000m<=200000, t=0t=0. No edges are added or removed. Score: 55.

55~66: n<=100000n<=100000, m<=200000m<=200000, t<=100000t<=100000. No edges disappear. Score: 1010.

77~88: n<=100000n<=100000, m<=200000m<=200000, t<=100000t<=100000. No edges appear. Score: 1010.

99~1010: n<=100000n<=100000, m<=200000m<=200000, t<=100000t<=100000. No more than 10001000 edges disappear. Score: 1515.

In addition, for all data, 0<ui,uj,vi,vj<=n0<u_i,u_j,v_i,v_j<=n, 0<=wi,wj<=100<=w_i,w_j<=10, 0<tmj<=10t0<tm_j<=10t, and all tmjtm_j are distinct. The testdata guarantees that there is no positive cycle.

Translated by ChatGPT 5