RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00090

Najkraci

Platinum II 플래티넘 II
난이도
5s
시간 제한
32MB
메모리 제한
1
맞았습니다!!
2
제출 수
50.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 roads such that the 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 contain that road, modulo \(1\,000\,000\,007\).

제약

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.
Contest #3, \(13^{th}\) December 2008

입력 형식

The first line contains two integers \(N\) and \(M\) (\(1 \le N \le 1500\), \(1 \le M \le 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 \(10000\).

출력 형식

Output \(M\) integers each on its own line – for each road, the number of different shortest paths containing it, modulo \(1\,000\,000\,007\). The order of these numbers should match the order of roads in the input.

Scoring: 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\).

서브태스크
서브태스크점수설명

Subtask 1

130점
예제 1
입력
4 3
1 2 5
2 3 5
3 4 5
출력
3
4
3
예제 2
입력
4 4
1 2 5
2 3 5
3 4 5
1 4 8
출력
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
출력
0
4
6
6
6
7
2
6
문제 정보

riseoj 작성

출처 COCI 2008/2009 Contest 3

평가 및 의견

Najkraci

개요
출제자 난이도 Platinum II 플래티넘 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Najkraci

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8