A1159 | [COCI-2008_2009-contest3]#5 NAJKRACI
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A road network in a country consists of N cities and M one-way roads. The cities are numbered 1 through N. For each road we know the origin and destination cities, as well as its length.
We say that the road F is a continuation of road E if the destination city of road E is the same as the origin city of road F. A path from city A to city B is a sequence of road such that origin of the first road is city A, each other road is a continuation of the one before it, and the destination of the last road is city B. The length of the path is the sum of lengths of all roads in it.
A path from A to B is a shortest path if there is no other path from A to B that is shorter in length.
Your task is to, for each road, output how many different shortest paths containing that road, modulo 1 000 000 00
7.
We say that the road F is a continuation of road E if the destination city of road E is the same as the origin city of road F. A path from city A to city B is a sequence of road such that origin of the first road is city A, each other road is a continuation of the one before it, and the destination of the last road is city B. The length of the path is the sum of lengths of all roads in it.
A path from A to B is a shortest path if there is no other path from A to B that is shorter in length.
Your task is to, for each road, output how many different shortest paths containing that road, modulo 1 000 000 00
7.
输入格式
The first line contains two integers N and M (1 ≤ N ≤ 1500, 1 ≤ M ≤ 5000), the number of cities and roads.
Each of the following M lines contains three positive integers O, D and L. These represent a one-way road from city O to city D of length L. The numbers O and D will be different and L will be at most 1000
0.
Each of the following M lines contains three positive integers O, D and L. These represent a one-way road from city O to city D of length L. The numbers O and D will be different and L will be at most 1000
0.
输出格式
Output M integers each on its own line – for each road, the number of different shortest paths containing it, modulo 1 000 000 00
7. The order of these numbers should match the order of roads in the input.
7. The order of these numbers should match the order of roads in the input.
输入输出样例
输入 #1
4 3 1 2 5 2 3 5 3 4 5
输出 #1
3 4 3
输入 #2
4 4 1 2 5 2 3 5 3 4 5 1 4 8
输出 #2
2 3 2 1
输入 #3
5 8 1 2 20 1 3 2 2 3 2 4 2 3 4 2 3 3 4 5 4 3 5 5 4 20
输出 #3
0 4 6 6 6 7 2 6
In test cases worth 30% of points, N will be at most 15 and M will be at most 30.
In test cases worth 60% of points, N will be at most 300 and M will be at most 1000.
In test cases worth 60% of points, N will be at most 300 and M will be at most 1000.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted