CF1383F.Special Edges
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Koa the Koala has a directed graph G with n nodes and m edges. Each edge has a capacity associated with it. Exactly k edges of the graph, numbered from 1 to k , are special, such edges initially have a capacity equal to 0 .
Koa asks you q queries. In each query she gives you k integers w1,w2,…,wk . This means that capacity of the i -th special edge becomes wi (and other capacities remain the same).
Koa wonders: what is the maximum flow that goes from node 1 to node n after each such query?
Help her!
输入格式
The first line of the input contains four integers n , m , k , q ( 2≤n≤104 , 1≤m≤104 , 1≤k≤min(10,m) , 1≤q≤2⋅105 ) — the number of nodes, the number of edges, the number of special edges and the number of queries.
Each of the next m lines contains three integers u , v , w ( 1≤u,v≤n ; 0≤w≤25 ) — the description of a directed edge from node u to node v with capacity w .
Edges are numbered starting from 1 in the same order they are listed in the input. The first k edges are the special edges. It is guaranteed that wi=0 for all i with 1≤i≤k .
Each of the next q lines contains k integers w1,w2,…,wk ( 0≤wi≤25 ) — the description of the query. wi denotes the capacity of i -th edge.
输出格式
For the i -th query, print one integer resi — the maximum flow that can be obtained from node 1 to node n given the i -th query's special edge weights.
输入输出样例
输入#1
2 1 1 3 1 2 0 0 1 2
输出#1
0 1 2
输入#2
4 4 2 5 1 2 0 2 3 0 2 4 5 3 4 2 0 0 1 10 10 0 7 1 7 2
输出#2
0 1 5 6 7
说明/提示
For the second sample, the following images correspond to the first two queries (from left to right respectively). For each edge there is a pair flow/capacity denoting flow pushed through the edge and edge's capacity. The special edges are colored in red.
As you can see in first query maximum flow from node 1 to node 4 equals 0 and in second query equals 1 .