QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601553#5075. Fenwick TreegozoniteWA 79ms3608kbC++141.3kb2024-09-30 07:01:352024-09-30 07:01:35

Judging History

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

  • [2024-09-30 07:01:35]
  • 评测
  • 测评结果:WA
  • 用时:79ms
  • 内存:3608kb
  • [2024-09-30 07:01:35]
  • 提交

answer

#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <deque>
#include <queue>
#include <tuple>
#include <cmath>
#include <cctype>
#include <stack>
#include <cassert>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
using ll = long long;

int n;
int c[100001];

int main() {
    // freopen("L.in", "r", stdin);
    // freopen("L.out", "w", stdout);

    int T; cin >> T;
    while (T--) {
        cin >> n;
        string s; cin >> s; s = " " + s;
        for (int i = 1; i <= n; i++) c[i] = s[i]-'0';
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i%2 == 1) { ans += (c[i]==1); continue; }
            int pwr = i&-i;
            int j = i-pwr;
            int zc = 0, oc = 0;
            while (pwr % 2 == 0) {
                pwr >>= 1;
                j += pwr;
                if (c[j] == 0) zc++;
                else oc++;
                
            }
            if (zc == oc) continue;
            if (c[i] == 1 && oc == 0) ans++;
            else if (c[i] == 0 && oc == 1) ans++;
        }
        cout << ans << endl;
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3608kb

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: 79ms
memory: 3496kb

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
1
0
2
2
0
0
0
1
0
1
2
0
0
1
2
1
0
1
1
0
0
2
2
1
0
2
2
1
0
2
2
0
0
2
2
0
0
2
0
1
1
0
0
0
0
0
0
0
2
2
1
2
0
1
0
2
2
0
2
1
0
2
2
0
1
0
2
0
0
1
1
0
0
0
1
1
0
2
0
0
0
0
2
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
2
0
1
0
0
2
0
0
0
1
0
0
1
2
0
0
2
0
1
0
0
2
0
2
0
0
0
1
0
0
1
1
1
0
...

result:

wrong answer 9th numbers differ - expected: '2', found: '1'