QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290106#5072. Future CoderRemakee#WA 0ms3864kbC++14973b2023-12-24 13:29:022023-12-24 13:29:03

Judging History

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

  • [2023-12-24 13:29:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2023-12-24 13:29:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
const int N=1e5+10;
int T,n,ans;
char str[N];
namespace BIT
{
    int vis[N];
    #define lowbit(x) ((x)&(-x))
    inline void Add(int x,int v)
    {
        for(x;x<=n;x+=lowbit(x)) vis[x]+=v;
    }
}
using namespace BIT;
int main()
{
    T=read();
    while(T--)
    {
        n=read();
        for(int i=1;i<=n;i++) vis[i]=0;
        scanf("%s",str+1);
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            if(str[i]=='1'&&!vis[i]) Add(i,1),ans++;
            if(str[i]=='0'&&vis[i]==1) Add(i,-1),ans++;
            if(str[i]=='0'&&vis[i]>1) Add(i,-vis[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3864kb

input:

2
8
3 -1 4 1 -5 9 2 -6
1
0

output:

0
0

result:

wrong answer 1st numbers differ - expected: '19', found: '0'