$P4305 [JLOI2011]不重復數字$
阿新 • • 發佈:2019-03-27
emp abs for () lin har get sin getch
此題用桶肯定行不通
所以果斷選擇用\(MAP\)
不過看標簽貌似是\(hash\) 反正我用桶做的
#include <bits/stdc++.h> #define Abs(x) x?x:-x #define Max(a,b) a>b?a:b #define Min(a,b) a<b?a:b #define f(i,j,n) for(register int i=j;i<=n;i++) #define F(i,j,n) for(register int i=j;i>=n;i--) using namespace std; typedef long long ll; int t; int n; map<int , bool>mp; namespace solve{ inline ll read() { ll x=0,f=1; char ch=getchar(); while(!isdigit(ch)) (ch=='-')&(f=-1),ch=getchar(); while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return x*f; } template <typename T> inline void Write(T x) { if(x<0)(putchar('-'),x=-x); if(x>9)(Write(x/10)); putchar(x%10+'0'); return ; } template <typename X,typename Y> inline ll Gcd(X x,Y y) {return y?Gcd(y,x%y):x;} template <typename X,typename Y> inline ll Lcd(X x,Y y) {return x*y/Gcd(x,y);} void Main(){ #ifdef Open freopen(".in","r",stdin),freopen(".out","w",stdout); #endif ios::sync_with_stdio(false),cin.tie(0); mp.clear(); t=read(); while (t-- ){ n=read();mp.clear(); f(i,1,n) { int x=read(); if(!mp[x]) Write(x),putchar(' '); mp[x]=true; } puts(""); } } }; signed main() {return solve::Main(),0;}
$P4305 [JLOI2011]不重復數字$