QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282350#3242. 骰子旅行kilo_tobo_tarjen#WA 98ms8180kbC++201.5kb2023-12-11 20:34:422023-12-11 20:34:43

Judging History

你现在查看的是最新测评结果

  • [2023-12-11 20:34:43]
  • 评测
  • 测评结果:WA
  • 用时:98ms
  • 内存:8180kb
  • [2023-12-11 20:34:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int inv[110];
void add(int &x,int y){
    if((x+=y)>=mod)x-=mod;
}
void del(int &x,int y){
    if((x-=y)<0)x+=mod;
}
void init(){
    inv[0]=1;
    inv[1]=1;
    for(int i=2;i<110;i++){
        inv[i]=(long long)(mod-mod/i)*inv[mod%i]%mod;
    }
}
int p[110][110][110],g[110][110];
int siz[110];
vector<int> ve[110];
signed main()
{
    init();
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,s0,T;
    cin>>n>>s0>>T;
    for(int i=1;i<=n;i++){
        cin>>siz[i];
        for(int j=0;j<siz[i];j++){
            int x;cin>>x;
            p[i][x][1]=inv[siz[i]];
            ve[i].push_back(x);
        }
    }
    for(int i=1;i<T;i++){
        for(int x=1;x<=n;x++){
            for(int y=1;y<=n;y++)if(x!=y){
                for(auto &to:ve[y])add(p[x][to][i+1],1ll*p[x][y][i]*inv[siz[y]]%mod);
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int t=1;t<=T;t++)add(p[i][j][t],p[i][j][t-1]);
        }
    }
    g[s0][0]=1;
    int ans=0;
    for(int i=0;i<T;i++){
        for(int x=1;x<=n;x++){
            // if(g[x][i])cout<<"g["<<x<<"]["<<i<<"]="<<g[x][i]<<"\n";
            for(auto &to:ve[x]){
                add(ans,1ll*g[x][i]*inv[siz[x]]%mod*p[to][x][T-i-1]%mod*to%mod);
                add(g[to][i+1],1ll*g[x][i]*inv[siz[x]]%mod);
            }
        }
    }
    cout<<ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 98ms
memory: 8180kb

input:

100 30 100
51 8 80 45 28 2 36 19 49 74 41 24 65 3 87 7 88 10 77 91 55 92 59 69 98 84 73 83 31 40 35 23 94 62 71 46 86 12 82 5 81 33 29 9 89 22 38 44 70 14 11 60
48 15 13 48 12 23 28 42 18 27 21 43 57 96 34 2 58 73 52 70 31 76 24 82 64 39 100 75 49 56 79 14 97 92 6 33 22 3 47 8 1 32 78 4 90 45 59 44 ...

output:

714549863

result:

wrong answer 1st lines differ - expected: '882477706', found: '714549863'