QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#143450#6701. BaoBao Loves Readingqzez#WA 1ms3728kbC++141.2kb2023-08-21 12:55:112023-08-21 12:55:11

Judging History

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

  • [2023-08-21 12:55:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2023-08-21 12:55:11]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e5+5,M=N*4+5,K=31650,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,m,A[N],f[N],ans[N];
namespace BIT{
	int f[N];
	void Cl(){fill(f+1,f+n+1,0);}
	void add(int x,int y){while(x<=n) f[x]+=y,x+=x&-x;}
	int qry(int x){int ans=0;while(x) ans+=f[x],x-=x&-x;return ans;}
}
void Solve(){
	int i,j;scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&A[i]);
	fill(f+1,f+n+1,0);fill(ans+1,ans+n+1,0);BIT::Cl();
	for(i=1;i<=n;i++){
		if(f[A[i]]) {int p=BIT::qry(i)-BIT::qry(f[A[i]]);ans[p]++;BIT::add(f[A[i]],-1);}
		else ans[n]++;
		BIT::add(i,1);f[A[i]]=i;
	}
	for(i=n-1;i;i--) ans[i]+=ans[i+1];
	for(i=1;i<=n;i++) printf("%d ",ans[i]);printf("\n");
}
int main(){
	int t;scanf("%d",&t);while(t--) Solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3728kb

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 '