QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#605503 | #7405. Stone Game | Hunster | WA | 112ms | 17560kb | C++20 | 1.4kb | 2024-10-02 17:30:43 | 2024-10-02 17:30:45 |
Judging History
answer
#include <bits/stdc++.h>
constexpr int N = 1000006;
constexpr int mod = (int)(1e9) + 7;
int pow2[N];
int n, m;
char s[N], t[N];
int a[N], b[N], a1[N], b1[N];
int main() {
pow2[0] = 1;
for (int i = 1; i < N; i++) pow2[i] = pow2[i - 1] * 2 % mod;
int T;
std::cin >> T;
while (T--) {
std::cin >> s >> t;
n = std::strlen(s);
m = std::strlen(t);
a[n] = 0;
for (int i = 0, c = 0; i < n; i++) {
c = (2 * c + (s[i] - '0')) % mod;
a[n - 1 - i] = c;
}
b[m] = 0;
for (int i = 0, c = 0; i < m; i++) {
c = (2 * c + (t[i] - '0')) % mod;
b[m - 1 - i] = c;
}
for (int i = 0; i < n; i++) a1[i] = (a[i] - a[i + 1]) % mod;
for (int i = 0; i < m; i++) b1[i] = (b[i] - b[i + 1]) % mod;
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
if (i & 1) {
c1 = (c1 + 1ll * a1[i] * b[i]) % mod;
c1 = (c1 + 1ll * a[i] * b1[i]) % mod;
c1 = (c1 - 1ll * a1[i] * b1[i]) % mod;
}
else {
c2 = (c2 + 1ll * a1[i] * b1[i]) % mod;
}
}
c3 = (1ll * a[0] * b[0] - c1 - c2) % mod;
printf("%d %d %d\n", (c1 + mod) % mod, (c3 + mod) % mod, (c2 + mod) % mod);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 17560kb
input:
3 111 111 1111 1111 10101010 1001010
output:
8 24 17 41 116 68 2546 6689 3345
result:
ok 9 tokens
Test #2:
score: -100
Wrong Answer
time: 112ms
memory: 16072kb
input:
181778 1 1 1011111011 11011010111100100111000110101010 1001010 110 1 1100111111110 110111 1110010000 1 11 10010110 1 1011111 11 1011001000 10110000 110 11111001 11011 11111001 11 1000 1 10 1111 10100 1111110 111000100 10 1101001111101 101110 100 10 1011 1 10001 1100 11 1000 11 11 1110101 1 11 110010...
output:
0 0 1 246155736 338905192 159527632 90517526 651202360 258280565 0 3327 3327 9889 26647 13624 0 1 2 1667 999996097 2393 1058 999997676 1558 25064 66822 33426 310 778 406 1318 3554 1851 4 12 8 0 1 1 57 157 86 11414 30328 15210 3390 6781 3391 1094 999998833 264 5 11 6 0 8 9 8 12 16 6 8 10 58 175 118 0...
result:
wrong answer 7th words differ - expected: '93', found: '90517526'