Submission #19291975


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,Q;
const ll mo=998244353;

ll dp[202020][2];

ll pat[202020];
ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	/*
	int TT=5;
	dp[0][0]=1;
	FOR(i,9) {
		FOR(j,TT) {
			FOR(x,TT) dp[i+1][max(j,x)]+=dp[i][x];
			FOR(x,TT) dp[i+1][min(j,x)]+=dp[i][x];
			
		}
		
		FOR(j,TT) cout<<dp[i+1][j]<<" ";
		cout<<endl;
	}
	*/
	
	cin>>N>>M>>Q;
	
	ll P=1LL*N*(N+1)/2%mo;
	ll S=0;
	FOR(i,N) {
		pat[i]=1LL*(i+1)*(N-i);
		S+=pat[i];
	}
	ll ret=0;
	ll T=(S%mo)*modpow(P%mo*N)%mo;
	
	ll C=1LL*M*(mo+1)/2%mo;
	FOR(j,N) {
		T=pat[j]%mo*modpow(P)%mo;
		dp[0][0]=1;
		FOR(i,Q) {
			ll godown=1*modpow(2*M+1)%mo*T%mo;
			ll goup=(M-1)*modpow(2*M+1)%mo*T%mo;
			(ret+=dp[i][1]*T%mo*modpow(2*M+1)%mo*C)%=mo;
			dp[i+1][1]=(dp[i][0]*goup+dp[i][1]*(1+mo-godown))%mo;
			dp[i+1][0]=(dp[i][0]*(1+mo-goup)+dp[i][1]*godown)%mo;
			//cout<<T<<" "<<dp[i+1][0]<<" "<<dp[i+1][1]<<" "<<ret<<endl;
		}
	}
	ret=ret*modpow(P*(2*M+1)%mo,Q)%mo;
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task F - Do you like query problems?
User kmjp
Language C++ (GCC 9.2.1)
Score 0
Code Size 1924 Byte
Status TLE
Exec Time 4410 ms
Memory 8036 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:29:10: warning: unused variable ‘k’ [-Wunused-variable]
   29 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:29:12: warning: unused variable ‘l’ [-Wunused-variable]
   29 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:29:14: warning: unused variable ‘r’ [-Wunused-variable]
   29 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:29:16: warning: unused variable ‘x’ [-Wunused-variable]
   29 |  int i,j,k,l,r,x,y; string s;
      |                ^
./Main.cpp:29:18: warning: unused variable ‘y’ [-Wunused-variable]
   29 |  int i,j,k,l,r,x,y; string s;
      |                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:80:38: note: in expansion of macro ‘FOR’
   80 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1000
Status
AC × 3
AC × 18
TLE × 22
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt
Case Name Status Exec Time Memory
0_000.txt AC 4 ms 3568 KB
0_001.txt AC 2 ms 3456 KB
0_002.txt AC 9 ms 3512 KB
1_003.txt AC 2 ms 3536 KB
1_004.txt AC 26 ms 4492 KB
1_005.txt AC 76 ms 6588 KB
1_006.txt AC 2 ms 3536 KB
1_007.txt AC 73 ms 6260 KB
1_008.txt AC 78 ms 6576 KB
1_009.txt AC 5 ms 3532 KB
1_010.txt AC 41 ms 4976 KB
1_011.txt AC 76 ms 6624 KB
1_012.txt AC 68 ms 4576 KB
1_013.txt TLE 4410 ms 6380 KB
1_014.txt TLE 4410 ms 6672 KB
1_015.txt AC 11 ms 3516 KB
1_016.txt TLE 4410 ms 7116 KB
1_017.txt TLE 4410 ms 7188 KB
1_018.txt AC 74 ms 4668 KB
1_019.txt TLE 4410 ms 5280 KB
1_020.txt TLE 4410 ms 7268 KB
1_021.txt AC 103 ms 5128 KB
1_022.txt TLE 4410 ms 6740 KB
1_023.txt TLE 4410 ms 8036 KB
1_024.txt AC 106 ms 5084 KB
1_025.txt TLE 4410 ms 6972 KB
1_026.txt TLE 4410 ms 7824 KB
1_027.txt AC 105 ms 5092 KB
1_028.txt TLE 4410 ms 5868 KB
1_029.txt TLE 4410 ms 8036 KB
1_030.txt TLE 4410 ms 7976 KB
1_031.txt TLE 4410 ms 7916 KB
1_032.txt TLE 4410 ms 7976 KB
1_033.txt TLE 4410 ms 7984 KB
1_034.txt TLE 4410 ms 7876 KB
1_035.txt TLE 4410 ms 7916 KB
1_036.txt TLE 4410 ms 7972 KB
1_037.txt TLE 4410 ms 7956 KB
1_038.txt TLE 4410 ms 7820 KB
1_039.txt TLE 4410 ms 7820 KB