QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#765630 | #9489. 0100 Insertion | AllenJYL | RE | 1ms | 4028kb | C++14 | 2.9kb | 2024-11-20 14:52:01 | 2024-11-20 14:52:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define all(_array) (_array).begin(),(_array).end()
#define msp(_array) memset(_array,0x3f,sizeof _array)
#define ms0(_array) memset(_array,0,sizeof _array)
#define msn(_array) memset(_array,-1,sizeof _array)
#define mc(_tar,_array) memcpy(_tar,_array,sizeof _tar)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define TAK cout<<"TAK"<<endl
#define NIE cout<<"NIE"<<endl
#define OK cerr<<"OK"<<endl
#define pii pair<int,int>
#define endl '\n'
bool bg_memory;
mt19937 rnd(time(0));
int Case=1;
const int mod=998244353;
const int inf=2147483647;
const int bs=233;
const double eps=1e-6;
const int N=200,M=1e5+7;
template<class _t1,class _t2>inline void cmax(_t1 &a,_t2 b){a=a<b?b:a;}
template<class _t1,class _t2>inline void cmin(_t1 &a,_t2 b){a=a>b?b:a;}
inline int qp(int a,int b,int p=mod){int res=1;while(b){if(b&1)res=1ll*res*a%p;a=1ll*a*a%p;b>>=1;}return res;}
inline int sqrt(int x,int r){int l=0,ans=0;while(l<=r){if(1ll*mid*mid<=x) ans=mid,l=mid+1;else r=mid-1;}return ans;}
int dp[2][2][200][405];
string s;
int n;
void Main(){
cin>>n>>s;
reverse(all(s));
s=' '+s;
dp[0][0][0][N]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<2;j++){
for(int k=0;k<=n/3+1;k++){
for(int l=N-n;l<=N+n;l++) dp[i&1][j][k][l]=0;
}
}
if(s[i]!='0'){
for(int j=0;j<=(i-1)/3+1;j++){
for(int k=N-i+1;k<=N+j;k++){
if(k+3-N>j+1) continue;
(dp[i&1][1][max(j,k+3-N)][k+3]+=dp[(i&1)^1][0][j][k])%mod;
}
}
}
if(s[i]!='1'){
for(int j=0;j<=(i-1)/3+1;j++){
for(int k=N-i+1;k<=N+j;k++){
(dp[i&1][0][j][k-1]+=dp[(i&1)^1][0][j][k])%=mod;
(dp[i&1][0][j][k-1]+=dp[(i&1)^1][1][j][k])%=mod;
}
}
}
}
int ans=0;
for(int i=0;i<=n/3+1;i++) (ans+=dp[n&1][0][i][N])%=mod;
cout<<ans;
return;
}
string RdFile="";
bool en_memory;
signed main(){
auto bg_clock=chrono::high_resolution_clock::now();
#ifdef ONLINE_JUDGE
// freopen((RdFile+".in").c_str(),"r",stdin);
// freopen((RdFile+".out").c_str(),"w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cin>>Case;
while(Case--) Main();
auto en_clock=chrono::high_resolution_clock::now();
auto duration_clock=chrono::duration_cast<chrono::microseconds>(en_clock-bg_clock);
double duration_count=duration_clock.count()*0.001;
double memory_used=(&en_memory-&bg_memory)/1024.0/1024;
// cerr<<"Time:"<<duration_count<<"ms"<<endl;
// cerr<<"Memory: "<<memory_used<<"MB"<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3724kb
input:
8 0??0?100
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
4 ?10?
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4028kb
input:
28 ???????????0???0??????1???0?
output:
2023
result:
ok "2023"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
4 ????
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3960kb
input:
8 11111111
output:
0
result:
ok "0"
Test #6:
score: -100
Runtime Error
input:
500 ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...