QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290106 | #5072. Future Coder | Remakee# | WA | 0ms | 3864kb | C++14 | 973b | 2023-12-24 13:29:02 | 2023-12-24 13:29:03 |
Judging History
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;
}
詳細信息
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'