40分求助,后面的点全WA了
查看原帖
40分求助,后面的点全WA了
660676
get_lost楼主2022/2/27 22:59
#include <iostream>

using namespace std;
typedef long long LL;


const LL MOD = 80112002;
const int N = 5010;
LL dp[N];
bool ani[N][N];
bool st[N];
int n,m;

LL f(int k){
    LL &x = dp[k];
    if(x != 0) return x;
    for(int i = 1; i <= n; i++){
        if(ani[k][i] == 1)
            x += f(i);
    }
    if(x == 0) x = 1;
    return x;
}

int main()
{
    cin >> n >> m;
    while(m--){
        int a,b;
        cin >> a >> b;
        ani[a][b] = 1;
        st[b] = true;
    }
    LL res = 0;
    for(int i = 1; i <= n; i++){
        if(st[i] == false)  res += f(i);
        res %= MOD;
    }
    cout << res;
    return 0;
}
2022/2/27 22:59
加载中...