竞赛讨论区 > 为什么D题会WA啊!?
头像
静殁
发布于 2022-07-31 10:48
+ 关注

为什么D题会WA啊!?

#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
#define N 410
int dp[15][N][N]={0};
int n, q;
const int mod = 998244353;
inline ll read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

long long dpow(long long a,long long b){
    long long ans=1;
    while(b){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int solve(int a,int b,int c){
	int num=0;
	for(int i=0;i<n;i++){
		if(dp[i][a][b]<=c) num++;
	}
	return num;
}
int main() {
    n=read();
	q=read();
    memset(dp,N,sizeof(dp));
    for(int i=0;i<n;i++){
    	int m;
    	m=read();
		for(int j=0;j<m;j++){
			int a,b,c;
			a=read();
			b=read();
			c=read();
			
			for(;a<=400;a++){
				for(;b<=400;b++){
					dp[i][a][b]=min(dp[i][a][b],c);
				}
			}
		}
	}
	
	ll seed=read();
	std::mt19937 rng(seed);
	std::uniform_int_distribution<> u(1, 400);
	ll lastans = 0;
	ll ans = 0;
	for (int i = 1;i <= q;i++){
	    int IQ = (u(rng) ^ lastans) % 400 + 1;  // The IQ of the i-th friend
	    int EQ = (u(rng) ^ lastans) % 400 + 1;  // The EQ of the i-th friend
	    int AQ = (u(rng) ^ lastans) % 400 + 1;  // The AQ of the i-th friend
	    lastans = solve(IQ, EQ, AQ);  // The answer to the i-th friend
	    ans = (ans + (lastans*dpow(seed, q - i))%mod) % mod;
//	    cout<<IQ<<' '<<EQ<<' '<<AQ<<endl;
	}
	cout << ans << endl;

    return 0;
}
求各位大佬帮忙看看,是思路就有问题,还是其他的细节出了毛病

全部评论

(0) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐