QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#614785 | #6701. BaoBao Loves Reading | zqx# | WA | 0ms | 3536kb | C++23 | 1.4kb | 2024-10-05 16:56:32 | 2024-10-05 16:56:41 |
Judging History
answer
#include<bits/stdc++.h>
#define AC return 0;
#define int long long
#define pii pair<int,int>
#define all(tar) tar.begin(),tar.end()
const int maxx=2e5+5;
const int mod=998244353;
using namespace std;
int n,t;
struct Fenwick_tree
{
static const int N = 3e5 + 10;
int t[N];
#define lowbit(x) (x & -x)
void Add(int x, int v)
{
for (int i = x; i <= n; i += lowbit(i))
t[i] += v;
}
int Ask(int x) {
int res = 0;
for (int i = x; i > 0; i -= lowbit(i))
res += t[i];
return res;
}
int Query(int l, int r)
{
return Ask(r) - Ask(l - 1);
}
}bit;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--){
cin>>n;
vector<int>pre(n+1,0),ans(n+1,0);
for(int i=1;i<=n;i++){
bit.t[i]=0;
}
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(!pre[x]){
ans[n]++;
pre[x]=i;
bit.Add(i,1);
}else {
int sum=bit.Query(pre[x],i);
ans[sum-1]++;
bit.Add(pre[x],-1);
bit.Add(i,1);
pre[x]=i;
}
}
for(int i=n-1;i>=1;i--){
ans[i]+=ans[i+1];
}
for(int i=1;i<=n;i++)cout<<ans[i]<<" "[i==n];
cout<<'\n';
}
AC
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3536kb
input:
1 7 4 3 4 2 3 1 4
output:
7 6 5 4 4 4 4
result:
wrong answer 1st lines differ - expected: '7 6 5 4 4 4 4', found: '7 6 5 4 4 4 4'