QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401120#5075. Fenwick TreedoziccWA 13ms3808kbC++14755b2024-04-27 22:40:112024-04-27 22:40:11

Judging History

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

  • [2024-04-27 22:40:11]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3808kb
  • [2024-04-27 22:40:11]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n; cin>>n;
        string s; cin>>s;
        int rez=0;
        for(int i=0; i<n; i++)
        {
            if(s[i]=='1' and i%2==0){rez++; continue;}
            int st=((i+1)&(-i-1))/2; int pos=i-st;
            if(st==2 and s[i]!=s[i-2]){rez++; continue;}
            if(s[i]=='0')continue;
            bool ch=false;
            while(st>0)
            {
                if(s[pos]=='1'){ch=true; break;}
                st/=2; pos+=st;
            }
            if(!ch)rez++;
        }
        cout<<rez<<"\n";
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

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: 13ms
memory: 3556kb

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

result:

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