QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#958852 | #10077. The Cypriote Mermaid | lalaouye | AC ✓ | 5ms | 7168kb | C++20 | 1.7kb | 2025-03-31 11:02:36 | 2025-03-31 11:02:37 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define rep(i, l, r) for (int i (l); i <= (r); ++ i)
#define rrp(i, l, r) for (int i (r); i >= (l); -- i)
#define eb emplace_back
using namespace std;
#define pii pair <int, int>
#define inf 1000000000
#define ls (p << 1)
#define rs (ls | 1)
constexpr int N = 2e5 + 5, M = 1e6, P = 998244353, B = 400;
typedef long long ll;
typedef unsigned long long ull;
inline int rd () {
int x = 0, f = 1;
char ch = getchar ();
while (! isdigit (ch)) {
if (ch == '-') f = -1;
ch = getchar ();
}
while (isdigit (ch)) {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar ();
}
return x * f;
}
int qpow (int x, int y) {
int ret (1);
for (; y; y >>= 1, x = x * x % P) if (y & 1) ret = ret * x % P;
return ret;
}
int n, fac[N], ifac[N];
char s[N];
int c0, c1;
int C (int n, int m) {
if (m > n || m < 0) return 0;
return fac[n] * ifac[m] % P * ifac[n - m] % P;
}
int32_t main () {
// freopen ("1.in", "r", stdin);
// freopen ("1.out", "w", stdout);
scanf ("%s", s + 1);
n = strlen (s + 1);
fac[0] = 1;
rep (i, 1, n) fac[i] = fac[i - 1] * i % P;
ifac[n] = qpow (fac[n], P - 2);
rrp (i, 1, n) ifac[i - 1] = ifac[i] * i % P;
rep (i, 1, n) if (i & 1) {
if (s[i] == '0') s[i] = '1'; else if (s[i] == '1') s[i] = '0';
}
rep (i, 1, n) c0 += s[i] == '0', c1 += s[i] == '1';
int cnt (0), all (0);
rep (i, 1, n) {
if ((i & 1) && s[i] == '?') ++ cnt;
if (s[i] == '?') ++ all;
}
int ans (0);
rep (i, 0, cnt) {
int k = c1 + 2 * i - c0 + all - 2 * cnt;
if (k & 1) continue;
int j = k / 2;
(ans += C (cnt, i) * C (all - cnt, j)) %= P;
} cout << ans;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5968kb
input:
01?1??
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5964kb
input:
0?1?1000???0?0010?0?
output:
70
result:
ok 1 number(s): "70"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
0??01111011??111
output:
4
result:
ok 1 number(s): "4"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
0???10??1?1?????11?0??0?0??0??0?????1???1????10?11
output:
565722720
result:
ok 1 number(s): "565722720"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
?11?1?????????11???0????1???0?????1??1?????1?000???????0???1?11????????????1??0??????????10???0??0??
output:
287125838
result:
ok 1 number(s): "287125838"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5964kb
input:
?0???1???1?0??0?????????00??0?0???1???0?????????1??0???1?1?????1?0?0??01???0???1?0?10???1?????00??1???11?10????1?????11????????11??0?1?????1???0????00?0??????0??1???????????0???0???1?1?0???10????????1?????1??????????????0?00????????1??1?0????0???????1???1?110??0?1?????1???1????1????????????0???1???1...
output:
511534586
result:
ok 1 number(s): "511534586"
Test #7:
score: 0
Accepted
time: 0ms
memory: 5964kb
input:
00011000110110100000110010110010110001000010110100110010110001010001101101110101?110011010011000?011000000000011010001110111101010010011110000101010001010110011010001000011100101?1010101000011001111001000001001110110011111000000100011111000110110001011000101110000100001100000101101011111110010000000...
output:
6
result:
ok 1 number(s): "6"
Test #8:
score: 0
Accepted
time: 0ms
memory: 5960kb
input:
??11110???1??????0??01??0???110??00?1?1?1100?10?1??10?????0??10???0110????0?1101???1?0?010?11??0?1111??????????1????10?0??100???00?1???0?01?01?0????0??11?010???01?0??0?????00??1?0???00???????0????0001??10??0??1010?01??01?1?1?11?1??00?001?11?0?0?0?1?0??????11???0??010???0110?01??0????00??01??????10?0...
output:
466401736
result:
ok 1 number(s): "466401736"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
??????????????????0???1?1???????1?????????????????????????????????????0????0??1??0??????????0??????????????????????????????????1???????????????????1????????????????????????????0??????????????????????????????1???????????0?????????????1????1?????????1???????????????????????????????0???????????????????...
output:
811681097
result:
ok 1 number(s): "811681097"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
111????0????00??00?1101??1?0001???010?10010?10110000?11??11101?0?1?00???10??1?010?01?10????0??01????0?010?0??1??0??01??00?10011????0?0??0?001?1011?00??110?011101010?????1?0???11?110??0100100?1??0?01??01?000?0????0?01?1111?11?11???00?0101???0?1110?1?0111?1??11??1111011?0?0101???10?0101011???10??00011...
output:
154048253
result:
ok 1 number(s): "154048253"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
???0?1?00???01?01111?1?1???0??1011?0??0?10?110?000010?????0??0?000??00?010????00???100?0??10?0?01?01?1110000??001??0?00111??111
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 0ms
memory: 5888kb
input:
01010100000001010101?0010101010101010101010?01010101010101?10111010101010101010101010100010101010100010?010101010101000101010101010101010?01?101010001010101010101010101010101010101010101010101010101010101010101010101010101?1010101010101010101010101010101010101010101010001010?01010101010?01010?010101...
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 5ms
memory: 7168kb
input:
0101010?0????10?010?0??10101010101??0?01010101010101010101??0?1????10??101?1?101010?010101010?011??10?0101??01010?0?010?010101?1010101010?01010??1?10???01?11?010?0?01??01010101??0?010101110?010?0111?10?0??101?101?10101???10?1101?101???100???101?10??1?1?10??1?????11101?10??1?1?1?101?1?10?01010?01??01...
output:
0
result:
ok 1 number(s): "0"
Test #14:
score: 0
Accepted
time: 0ms
memory: 5888kb
input:
0010101010101010101010101010101?10101010101010101100101010101010101010101010101010101010?01010?010?0?0101010101010101010101010101010101000101?10?0111011101010101??010101011101010101?1010101010101010101010101010111?10?000101010?0101010?0101010101010101010101010?000101010101010101011101010101011101010...
output:
0
result:
ok 1 number(s): "0"
Test #15:
score: 0
Accepted
time: 0ms
memory: 6528kb
input:
010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...
output:
0
result:
ok 1 number(s): "0"
Test #16:
score: 0
Accepted
time: 1ms
memory: 7168kb
input:
10101010100010101110101010101010101010101010101010101010101011001010101010111110101011101010101010101010101010101010101010101000111010001010101010100010000010101010101010101110101010101010101110101010101011111010101110?010101010101011101010101010101010101110101010101010101010101010101010101010101010...
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 3ms
memory: 7044kb
input:
0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010?01010101010101010101010101010101010101010101010101010101010101010101010101010101?1010101010101010101010101...
output:
0
result:
ok 1 number(s): "0"
Test #18:
score: 0
Accepted
time: 3ms
memory: 7052kb
input:
?1???00?0?010?110??1?0110101?1?1?0?00?1100011010001???0111100110??0??0000?10?0001???10?00?01?0??001101?0???1?11000?000?1010000??0?1????11????1111??111?0001?01?0??11010?1?10?????01?01?011?10??000?00?1?110??1?0?0001?01100?100?010101000011?10?0??10?1???0000?0001?01?0111?00101?1101010100??00001???010?00...
output:
574585470
result:
ok 1 number(s): "574585470"
Test #19:
score: 0
Accepted
time: 2ms
memory: 7056kb
input:
010000110000001110101110110101001010010101001011000110100101111110000011010011011101101000010010000010000101111010100110010001010010100110000001101010101000111010010110011000011111100001101010010101001001110101111000101000111101110001001011010010111101011011100011000100101100001110111000011110100011...
output:
1
result:
ok 1 number(s): "1"
Test #20:
score: 0
Accepted
time: 2ms
memory: 6752kb
input:
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
436496381
result:
ok 1 number(s): "436496381"
Test #21:
score: 0
Accepted
time: 3ms
memory: 6912kb
input:
0?01011110101000110?10111?0111?010?0110011?1001?100100010000?00?1010011001000?00110001101001010111?0011?0?1?111011101111110101000100101011100110010101?0000?00?0001010011011011?1?00?1110110110?110111?1000??10?0110??010?1?0?0?11011001?110?00011110?0000100?01111??11?11001101?1100?00001?1100?1?10??11100...
output:
552407607
result:
ok 1 number(s): "552407607"
Test #22:
score: 0
Accepted
time: 0ms
memory: 4352kb
input:
11000?0011?0100?1?111?01001?00111100?10?1010111100011?01?1110011000100011000?001110010100?00001?0010?1001100011100??00111010000111101000010?01000?00?11000111000001?1001110000111110100?11101001100?101010110?111011010101?00110010?001001000?0011110??01?00111??001?000010111111100000001110000011110011010...
output:
46527247
result:
ok 1 number(s): "46527247"
Test #23:
score: 0
Accepted
time: 1ms
memory: 6292kb
input:
110110111010111010010101101000111001000111010000110010100010100101010100111010100101100010101000111010101100001001101111101000010000110010110101010011011100010001000101111011001101100010011011111110010110011101011010111010111110100101010100010001110010011001010010011001000101111000101011100101001011...
output:
1
result:
ok 1 number(s): "1"
Test #24:
score: 0
Accepted
time: 1ms
memory: 6548kb
input:
101110011101101000011010101101000100001010010011100001111101101001101101010011111111001001010010010100000010011100100110110000000111110111111010011000000111111110011001000101110000010010101111000111001000010011000000011010000010101001010000011001010101011010011011110000001111011110011010001110000001...
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 2ms
memory: 6748kb
input:
0010010100011110100110110100?100100001010?01101100001001100?010010?00?010100111111011101001010100011001101100001?1100010100010100100011101001010110110111111?1111100110111010110000?1110100000111001001?01001011111?10001110001111000110100110100?11010010010?10101100010101?010000000000011000000001?010011...
output:
72476953
result:
ok 1 number(s): "72476953"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1
output:
0
result:
ok 1 number(s): "0"