爆零求助!

P4305 [JLOI2011] 不重复数字

没让你排序。。。
by WSCU_DZ_XM @ 2023-08-10 10:36:35


@[Zouzhuoxuan](/user/800322)
by WSCU_DZ_XM @ 2023-08-10 10:36:47


@[WSCU_DZ_XM](/user/740280) `sort+unique` 可以实现完整去重,我排序后又按照原顺序排了回去。
by Zouzhuoxuan @ 2023-08-10 12:53:25


@[Zouzhuoxuan](/user/800322) 可能有点晚回了。。 就是两个数index相同的时候要比较q.num<w.num ``` #include<bits/stdc++.h> #define int long long using namespace std; const int N=5e4+5; int n; struct node{ int x,y; }a[N]; bool cmp(node a,node b){//这里 if(a.x!=b.x){ return a.x<b.x; }else return a.y<b.y; } bool Cmp(node a,node b){ return a.y<b.y; } bool CMP(node a,node b){ return a.x==b.x; } signed main(){ int T; cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i].x,a[i].y=i; sort(a+1,a+n+1,cmp); n=unique(a+1,a+n+1,CMP)-a-1; sort(a+1,a+n+1,Cmp); for(int i=1;i<=n;i++) cout<<a[i].x<<" "; cout<<endl; } return 0; } ```
by huafuzhe @ 2024-03-22 20:03:28


|