为啥这样能爆零??
查看原帖
为啥这样能爆零??
1062697
hellocccl楼主2024/1/3 19:22
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
vector<int>a;
int c[N];
void solve(){
    int n;cin>>n;
    memset(c,0,sizeof(int)*(n+1));
    for(int i =1;i<=n;i++){
        int x;cin>>x;
        if(c[x]==0){
            a.push_back(x);
            c[x]=1;
        }
    }
    for(auto i :a){
        cout<<i<<" ";
    }
    cout<<'\n';
    a.clear();
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _;cin>>_;
    while(_--){
        solve();
    }
}
2024/1/3 19:22
加载中...