QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#83585 | #5075. Fenwick Tree | magicduck# | WA | 15ms | 3644kb | C++14 | 1.2kb | 2023-03-02 16:47:10 | 2023-03-02 16:47:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &F) {
int R = 1; F = 0; char CH = getchar();
for(; !isdigit(CH); CH = getchar()) if(CH == '-') R = -1;
for(; isdigit(CH); CH = getchar()) F = F * 10 + CH - 48;
F *= R;
}
inline void file(string str) {
freopen((str + ".in").c_str(), "r", stdin);
freopen((str + ".out").c_str(), "w", stdout);
}
const int N = 1e5 + 10;
char s[N]; int n;
int main() {
//file("");
int T; read(T);
while(T--) {
read(n); scanf("%s", s + 1);
int ans = 0;
for(int i = 1; i <= n; i++) {
int cnt = 0, x = i - 1;
if(!(i & 1)) {
if(s[x] == '1') cnt++;
for(int j = 1; j < (i & -i); j <<= 1) {
x -= j; if(s[x] == '1') cnt++;
}
}
if(cnt == 0 && s[i] == '1') ans++;
else if(cnt == 1 && s[i] == '0') ans++;
}
cout << ans << '\n';
}
#ifdef _MagicDuck
fprintf(stderr, "# Time: %.3lf s", (double)clock() / CLOCKS_PER_SEC);
#endif
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3644kb
input:
3 5 10110 5 00000 5 11111
output:
3 0 3
result:
ok 3 number(s): "3 0 3"
Test #2:
score: -100
Wrong Answer
time: 15ms
memory: 3576kb
input:
100000 10 0000000000 10 0000000100 10 0000000000 10 1000000000 10 0000010000 10 0000000000 10 0000000000 10 0000000000 10 0100000000 10 0000000000 10 0000000001 10 0000001000 10 0000000000 10 0000000000 10 0000000001 10 0000100000 10 0010000000 10 0000000000 10 0010000000 10 0000000001 10 0000000000...
output:
0 2 0 2 2 0 0 0 2 0 1 2 0 0 1 2 2 0 2 1 0 0 2 2 2 0 3 2 2 0 2 2 0 0 2 2 0 0 2 0 2 2 0 0 0 0 0 0 0 2 2 2 3 0 1 0 2 3 0 2 2 0 2 2 0 2 0 2 0 0 2 2 0 0 0 1 2 0 2 0 0 0 0 3 2 0 0 0 0 0 0 2 0 2 2 0 2 2 2 0 0 0 0 0 0 0 1 0 0 0 2 0 2 0 0 0 3 0 2 0 0 2 0 0 0 2 0 0 2 2 0 0 3 0 2 0 0 2 0 2 0 0 0 2 0 0 2 2 2 0 ...
result:
wrong answer 2nd numbers differ - expected: '1', found: '2'