QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#83585#5075. Fenwick Treemagicduck#WA 15ms3644kbC++141.2kb2023-03-02 16:47:102023-03-02 16:47:11

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-02 16:47:11]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3644kb
  • [2023-03-02 16:47:10]
  • 提交

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'