結果

問題 No.1677 mæx
ユーザー inksamuraiinksamurai
提出日時 2021-09-11 01:24:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 2,209 bytes
コンパイル時間 3,749 ms
コンパイル使用メモリ 167,876 KB
実行使用メモリ 9,248 KB
最終ジャッジ日時 2023-09-03 17:22:08
合計ジャッジ時間 2,628 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 8 ms
7,576 KB
testcase_05 AC 8 ms
7,592 KB
testcase_06 AC 7 ms
7,488 KB
testcase_07 AC 8 ms
7,452 KB
testcase_08 AC 8 ms
7,480 KB
testcase_09 AC 8 ms
7,472 KB
testcase_10 AC 8 ms
7,624 KB
testcase_11 AC 8 ms
7,636 KB
testcase_12 AC 8 ms
7,604 KB
testcase_13 AC 8 ms
7,532 KB
testcase_14 AC 8 ms
7,712 KB
testcase_15 AC 7 ms
7,508 KB
testcase_16 AC 7 ms
7,588 KB
testcase_17 AC 7 ms
7,496 KB
testcase_18 AC 8 ms
7,648 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 9 ms
9,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: ラムダ関数内:
main.cpp:75:9: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   75 |         };
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end());
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define vec(...) vector<__VA_ARGS__>
#define _3E0svGb ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using tpii=pair<pii,int>;
using vi=vec(int);
const int mod=998244353;

//snuke's modular int
struct modularint{
	ll x;
	modularint(ll x=0):x(x%mod){}
	modularint& operator+=(const modularint a){
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator-=(const modularint a){
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator*=(const modularint a){
		(x *= a.x) %= mod;
		return *this;
	}
	modularint operator+(const modularint a)const{
		modularint res(*this);
		return res+=a;
	}
	modularint operator-(const modularint a)const{
		modularint res(*this);
		return res-=a;
	}
	modularint operator*(const modularint a)const{
		modularint res(*this);
		return res*=a;
	}
	modularint pow(ll n)const{
		modularint res=1,x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	modularint inv()const{
		return pow(mod-2);
	}
};
using mint=modularint;

int main(){
_3E0svGb;
	string s;
	cin>>s;
	int i=0;
	auto mex=[&](int x,int y){
		rep(i,3) if(x!=i and y!=i) return i;
	};
	auto f=[&](auto self)->vec(mint){
		vec(mint) now(3);
		if(s[i]=='?' or (s[i]>='0' and s[i]<='9')){
			if(s[i]=='?') rep(t,3) now[t]=1;
			else now[int(s[i]-'0')]=1;
		}else{
			string h=s.substr(i,3);
			i+=4;
			vec(mint) l=self(self);
			i+=2;
			vec(mint) r=self(self);
			i++;
			if(h!="max"){
				rep(i,3)
					rep(j,3)
						now[mex(i,j)]+=l[i]*r[j];
			}
			if(h!="mex"){
				rep(i,3)
					rep(j,3)
						now[max(i,j)]+=l[i]*r[j];
			}
		}
		return now;
	};
	vec(mint) res=f(f);
	int k;
	cin>>k;
	printf("%lld\n",res[k].x);
//	
	return 0;
}
0