結果

問題 No.2872 Depth of the Parentheses
ユーザー 👑 kmjpkmjp
提出日時 2024-09-06 22:55:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,424 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 202,948 KB
実行使用メモリ 11,628 KB
最終ジャッジ日時 2024-09-06 22:55:08
合計ジャッジ時間 4,090 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 35 ms
11,572 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 10 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 34 ms
11,600 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 35 ms
11,628 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 34 ms
11,512 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 35 ms
11,512 KB
evil_01.txt RE -
evil_02.txt RE -
evil_03.txt RE -
evil_04.txt RE -
evil_05.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;}
//-------------------------------------------------------

ll dp[1<<20];
const ll mo=998244353;
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;
}
int X,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>K;
	
	dp[0]=1;
	ll a=X*modpow(100)%mo;
	ll b=(100-X)*modpow(100)%mo;
	int mask;
	FOR(i,2*K) {
		int mask;
		FOR(mask,1<<i) {
			dp[mask|(1<<i)]=dp[mask]*a%mo;
			dp[mask]=dp[mask]*b%mo;
		}
	}
	
	ll ret=0;
	FOR(mask,1<<(2*K)) {
		int cur=0;
		int d=0;
		FOR(i,2*K) {
			if(mask&(1<<i)) cur++;
			else cur--;
			if(cur<0) break;
			d=max(d,cur);
			
		}
		if(cur==0) (ret+=d*dp[mask])%=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;
}
0