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

Palacinke

Diamond IV 다이아몬드 IV
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Ana has a couple of classmates coming over for crêpes (known as palačinke in Croatian). They are coming in \(T\) minutes, and Ana just found out that she has neither one of the four required ingredients (flour, milk, eggs and jam). She hops into her car and drives around her neighbourhood buying supplies.

Her neighbourhood contains \(N\) crossroads numbered \(1\) to \(N\), and \(M\) one way roads connecting them. Ana starts on crossroad \(1\). On each road there is exactly one shop, selling some, maybe all, ingredients.

Ana needs \(1\) minute to drive down any given road if she does not stop in the shop, or \(2\) minutes if she does. She needs to obtain all ingredients and drive back to crossroad one in time. She likes to compare shop prices so she may enter a shop even if she already has all ingredients.

Write a program that will calculate the number of different ways Ana can buy the ingredients and return home in \(T\) minutes or less. Since this number can be very large, output it modulo \(5557\).

제약
입력 형식

The first line contains two integers \(N\) and \(M\) (\(1 \le N \le 25\), \(1 \le M \le 500\)), number of crossroads and roads.

Each of the next \(M\) lines contains two different integers \(u\) and \(v\) and a string \(s\), separated by exactly one space. They describe a road connecting crossroads \(u\) and \(v\) (directed from \(u\) to \(v\)), and the shop located on the road selling ingredients \(s\).

The string \(s\) will contain between \(1\) and \(4\) uppercase characters. Character B for flour, J for eggs, M for milk and P for jam.

There are at most two direct roads between two crossroads, and only if they are in opposite directions.

The last line contains one integer \(T\) (\(1 \le T \le 1\,000\,000\,000\)), time until Ana's friends arrive, in minutes.

출력 형식

The first and only line of output should contain the number of different ways Ana can buy the ingredients, modulo \(5557\).

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

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
3 3
1 2 BMJ
2 3 MJP
3 1 JPB
5
출력
3
예제 2
입력
3 4
1 2 B
2 1 P
1 3 J
3 1 M
8
출력
2
예제 3
입력
5 7
1 2 B
2 4 M
1 3 J
3 4 MB
4 1 JP
4 5 J
5 1 P
7
출력
5
문제 정보

riseoj 작성

출처 COCI 2009/2010 Contest 4

평가 및 의견

Palacinke

개요
출제자 난이도 Diamond IV 다이아몬드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Palacinke

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