QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706236 | #9464. 基础 01? 练习题 | Aaronwrq# | 10 | 786ms | 3872kb | C++14 | 885b | 2024-11-03 09:35:27 | 2024-11-03 09:35:28 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN 50010
using namespace std;
int n, m, q;
string S, T;
int ans;
void dfs(const int p, const int l, const int r) {
if (p > r) {
for (int lp = l; lp <= r; ++lp) for (int rp = lp; rp <= r; ++rp) {
int len = rp - lp + 1;
string tmp = S.substr(lp, len);
bool flag = 0;
for (int i = 0; i <= m - len; ++i) if (tmp == T.substr(i, len)) {flag = 1; break;}
ans += flag;
}
return;
}
if (S[p] != '?') dfs(p + 1, l, r);
else {
S[p] = '0', dfs(p + 1, l, r);
S[p] = '1', dfs(p + 1, l, r);
S[p] = '?';
}
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> q >> S;
T = "0", m = n << 2;
for (int i = 1; i < m; ++i) T += T[i >> 1] ^ (i & 1);
while (q--) {
int l, r; cin >> l >> r;
ans = 0;
dfs(l, l, r);
cout << ans << "\n";
}
return 0;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 119ms
memory: 3872kb
input:
15 15 0???0??01???1?? 2 14 0 9 6 10 1 14 1 14 0 12 5 14 6 7 0 6 4 14 1 12 10 10 0 14 1 12 4 7
output:
25883 2344 112 56425 56425 12963 4531 6 666 5212 11875 2 60786 11875 37
result:
ok 15 numbers
Test #2:
score: 10
Accepted
time: 0ms
memory: 3644kb
input:
15 15 011?1?0101??110 0 11 2 10 0 13 2 12 3 5 2 12 3 5 12 13 1 14 1 5 8 13 9 12 2 10 0 11 7 8
output:
803 285 952 732 23 732 23 3 940 48 69 37 285 803 3
result:
ok 15 numbers
Test #3:
score: 10
Accepted
time: 1ms
memory: 3840kb
input:
15 15 100110?1010?01? 9 9 6 11 1 4 0 13 7 7 9 13 3 14 0 0 0 13 0 12 0 10 6 11 4 8 3 13 0 13
output:
1 77 10 265 1 25 384 1 265 251 109 77 30 175 265
result:
ok 15 numbers
Test #4:
score: 10
Accepted
time: 786ms
memory: 3572kb
input:
15 15 ??????0?0?????? 8 10 0 14 9 12 2 13 1 6 7 12 0 13 6 14 0 11 0 14 4 14 5 14 0 8 4 5 1 13
output:
23 439848 146 41764 540 540 202272 3703 41802 439848 18776 8386 3703 12 92312
result:
ok 15 numbers
Test #5:
score: 10
Accepted
time: 11ms
memory: 3636kb
input:
15 15 ?1??0?0??010?1? 3 14 4 5 0 14 0 13 4 8 12 13 1 5 5 8 11 13 3 3 1 12 0 2 5 14 11 12 4 12
output:
3128 6 15531 6994 99 6 101 73 12 2 2842 23 1305 6 522
result:
ok 15 numbers
Test #6:
score: 10
Accepted
time: 10ms
memory: 3528kb
input:
15 15 10????1001?11?1 0 14 0 5 0 14 5 13 4 9 10 14 6 13 0 14 1 9 0 13 6 13 1 11 1 13 9 13 4 5
output:
4184 279 4184 276 78 46 109 4184 531 3878 109 1446 3516 46 12
result:
ok 15 numbers
Subtask #2:
score: 0
Time Limit Exceeded
Test #7:
score: 0
Time Limit Exceeded
input:
20 200000 ???10?10???????1???? 1 19 2 17 5 19 6 19 6 15 5 19 1 11 0 15 4 6 3 16 10 13 12 18 16 16 0 15 7 14 2 11 14 19 9 16 0 18 11 16 7 13 1 17 5 18 7 7 6 10 4 17 5 19 2 9 0 16 1 19 5 14 4 19 0 11 0 16 15 19 0 12 1 15 4 17 13 16 3 14 4 13 5 13 3 10 0 19 2 17 6 18 0 18 7 10 3 18 10 14 1 13 0 16 0 19...
output:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #13:
score: 0
Time Limit Exceeded
input:
50000 200000 011001101001011?10011001011010010110011010011001011?011010010110?0011001011001101?011?010?10100101100110100110010110011?1001011010011001011?10010?1?0?10100101101?01100101100110100110010110?001011001101001100101100?10100101101?0110?10110011010011001011010010110011010010110100110?10110100...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #19:
score: 0
Time Limit Exceeded
input:
50000 1 0101101001100101100110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010010110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010011001011001101001011010011001011010010110011010010110100110010110011010011001011010...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #25:
score: 0
Time Limit Exceeded
input:
50000 1 01011010011000110100110010110010?1001?0001011001101?001011001101?0101101?011011001101001010?10100101101001100101?01100101010?101001100110?1011010011001011010??110011?1?011001?1100110?101101001100101100100110010110011100110100101001?1?0?00?100101101001011001101001011100?1010010110101101001011...
output:
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #31:
score: 0
Time Limit Exceeded
input:
500 1000 011000100010010010010010110010101100101100101011010010011001101001011010011000010011010001011010000001100101100110100101101001001011010010110010110100101100111001100111010011010010110100110010110100101100110101000101100110100110010110100101100110100101101?01101101100101011001010010100110010...
output:
result:
Subtask #7:
score: 0
Time Limit Exceeded
Test #37:
score: 0
Time Limit Exceeded
input:
1000 2000 01100101101001011001101001011010011001011010010110011010011001011001101001011010011001011010010110011010000110100101101001100101100110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100110100110010110100101100110100101101001100101101001011001101001...
output:
result:
Subtask #8:
score: 0
Time Limit Exceeded
Test #43:
score: 0
Time Limit Exceeded
input:
5000 100000 ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
result:
Subtask #9:
score: 0
Time Limit Exceeded
Test #49:
score: 0
Time Limit Exceeded
input:
20000 100000 ????????????????????????????0??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
result:
Subtask #10:
score: 0
Time Limit Exceeded
Test #55:
score: 0
Time Limit Exceeded
input:
50000 200000 ?01101001011001?01?011?010?1001101001?110?001?0?1?1?001101?0110?101?010??01100110?00?1001011001101001011??001?001?110100101100110100101?01?0110?1011?011010011001?1?0100??110011?100?01101001100?011010?10??00110100?1?0?0110?1101?01??1?10??10010?10?00101?00??0???101101?0???010110??1?10011?...