QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#696833 | #9489. 0100 Insertion | Insert_Username_Here | WA | 809ms | 35224kb | C++20 | 1.1kb | 2024-11-01 02:56:48 | 2024-11-01 02:56:49 |
Judging History
answer
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll mod = 1e9 + 7;
// #include <brawlstars>
// FOR PAIN OR FOR GLORYYY ELLL PRIMOOOOOO
const ll N = 501;
ll dp[2][N * 4][N][2];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n;
string s;
cin >> n >> s;
reverse(s.begin(), s.end());
dp[0][n][0][0] = 1;
ll cur = 0, nxt = 1;
for(ll i = 0; i < n; i++) {
memset(dp[nxt], 0, sizeof dp[nxt]);
for(ll j = 0; j < 4 * n; j++) {
for(ll k = 0; k < N; k++) {
if(!dp[cur][j][k][0] && !dp[cur][j][k][1]) continue;
if(s[i] != '1') dp[nxt][j + 1][k][0] = (dp[nxt][j + 1][k][0] + dp[cur][j][k][0] + dp[cur][j][k][1]) % mod;
if(s[i] != '0') {
if(i == n - 1 || i < 2 || k < n + 2 - j) continue;
ll bk = max(n - j + 3, k);
dp[nxt][j - 3][bk][1] = (dp[nxt][j - 3][bk][1] + dp[cur][j][k][0]) % mod;
}
}
}
swap(cur, nxt);
}
ll ans = 0;
for(ll i = 0; i < n; i++) ans = (ans + dp[cur][n][i][0]) % mod;
cout << ans << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 35216kb
input:
8 0??0?100
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 3ms
memory: 34952kb
input:
4 ?10?
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 18ms
memory: 35224kb
input:
28 ???????????0???0??????1???0?
output:
2023
result:
ok "2023"
Test #4:
score: 0
Accepted
time: 0ms
memory: 34988kb
input:
4 ????
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 3ms
memory: 34920kb
input:
8 11111111
output:
0
result:
ok "0"
Test #6:
score: -100
Wrong Answer
time: 809ms
memory: 34964kb
input:
500 ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
467681810
result:
wrong answer 1st words differ - expected: '870731023', found: '467681810'