Problem 2962 --Milk

2962: Milk

"
Time Limit $3$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $18$ 正确数量 $4$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
As we all know, Tom loves milk very much, but he never manages to finish a bottle of milk by himself, cause Jerry always swallows at least half of it! 
But now, he is alone in the Wonderland of Milk! The Wonderland can be seen as a grid with nn rows and mm columns. Tom numbers the rows with integers from 11 to nn from top to bottom and the columns with integers from 11 to mm from left to right. He starts from the upper-left cell (1,1)(1,1)
Tom can move down if and only if he is in the middle column of the grid (the m+12m+12th column). Otherwise, he can only go left or right. Each movement takes him 11 second. 
There are kk bottles of milk on the grid. The iith bottle is located in the ririth row and cicith column, and Tom needs titi seconds to finish it. 
In order to enjoy the milk alone, he wants to do it as fast as possible. So he wants to know the minimum time he needs to finish i(i=1,2,⋯,k)i(i=1,2,⋯,k) bottles of milk.
The first line contains one integer T(1≤T≤2500)T(1≤T≤2500), the number of test cases. 
For each test case, the first line contains 33 integers n,m,k(3≤n,m≤109,1≤k≤104,∑k≤6×104)n,m,k(3≤n,m≤109,1≤k≤104,∑k≤6×104), where mm is guaranteed to be an odd number. 
Each of the next kk lines contains 33 integers ri,ci,ti(1≤ri≤n,1≤ci≤m,ci≠m+12,1≤ti≤109)ri,ci,ti(1≤ri≤n,1≤ci≤m,ci≠m+12,1≤ti≤109), the position of iith bottle of milk and the time it takes Tom to drink.
For each test case, output one line containing kk integers separated by space, the iith of which indicates the minimum time Tom needs to finish exactly ii bottles of milk.
1
7 7 2
3 7 1
4 5 1
8 15

推荐代码 查看2962 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$591 $ms] 刘成健 460864 2019-09-04 10:35:32
内存最少[$0 $KB] 淡意的温柔 605332 2020-07-03 14:50:16
第一AC 刘成健 460864 2019-09-04 10:35:32
第一挑战 刘成健 460864 2019-09-04 10:35:32

赛题来源/所属竞赛 2019 Multi-University Training Contest 1 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛