QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#614756 | #6701. BaoBao Loves Reading | zqx# | WA | 0ms | 3668kb | C++23 | 1.4kb | 2024-10-05 16:53:53 | 2024-10-05 16:53:55 |
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);
// cout<<i<<" "<<sum<<'\n';
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]<<" ";
cout<<'\n';
}
AC
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3668kb
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 '