CF283C.Coin Troubles

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the Isle of Guernsey there are nn different types of coins. For each ii (1<=i<=n)(1<=i<=n) , coin of type ii is worth aia_{i} cents. It is possible that ai=aja_{i}=a_{j} for some ii and jj (ij)(i≠j) .

Bessie has some set of these coins totaling tt cents. She tells Jessie qq pairs of integers. For each ii (1<=i<=q)(1<=i<=q) , the pair bi,cib_{i},c_{i} tells Jessie that Bessie has a strictly greater number of coins of type bib_{i} than coins of type cic_{i} . It is known that all bib_{i} are distinct and all cic_{i} are distinct.

Help Jessie find the number of possible combinations of coins Bessie could have. Two combinations are considered different if there is some ii (1<=i<=n)(1<=i<=n) , such that the number of coins Bessie has of type ii is different in the two combinations. Since the answer can be very large, output it modulo 10000000071000000007 (109+7)(10^{9}+7) .

If there are no possible combinations of coins totaling tt cents that satisfy Bessie's conditions, output 0.

输入格式

The first line contains three space-separated integers, n,qn,q and tt (1<=n<=300; 0<=q<=n; 1<=t<=105)(1<=n<=300; 0<=q<=n; 1<=t<=10^{5}) . The second line contains nn space separated integers, a1,a2,...,ana_{1},a_{2},...,a_{n} (1<=ai<=105)(1<=a_{i}<=10^{5}) . The next qq lines each contain two distinct space-separated integers, bib_{i} and cic_{i} (1<=bi,ci<=n; bici)(1<=b_{i},c_{i}<=n; b_{i}≠c_{i}) .

It's guaranteed that all bib_{i} are distinct and all cic_{i} are distinct.

输出格式

A single integer, the number of valid coin combinations that Bessie could have, modulo 10000000071000000007 (109+7)(10^{9}+7) .

输入输出样例

  • 输入#1

    4 2 17
    3 1 2 5
    4 2
    3 4
    

    输出#1

    3
    
  • 输入#2

    3 2 6
    3 1 1
    1 2
    2 3
    

    输出#2

    0
    
  • 输入#3

    3 2 10
    1 2 3
    1 2
    2 1
    

    输出#3

    0
    

说明/提示

For the first sample, the following 3 combinations give a total of 17 cents and satisfy the given conditions: 0 of type 1,1 of type 2,3 of type 3,2 of type 4,0,0,6,1,2,0,3,1{0 of type 1,1 of type 2,3 of type 3,2 of type 4},{0,0,6,1},{2,0,3,1} .

No other combinations exist. Note that even though 4 occurs in both bib_{i} and ci,c_{i}, the problem conditions are still satisfied because all bib_{i} are distinct and all cic_{i} are distinct.

首页