我小修了一下~~(但这并没有改变全TLE的问题)~~
```cpp
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int T, n;
inline ll read() {
ll k = 0, f = 1;
char ch = getchar();
while ( ch < '0' || ch > '9' ) {
if ( ch == '-' ) f = -1;
ch = getchar();
}
while ( ch >= '0' && ch <= '9' ) {
k = k * 10 + ( ch - '0' );
ch = getchar();
}
return k * f;
}
inline ll write ( ll x ) {
if ( x < 0 ) putchar ( '-' ), x = -x;
if ( x > 9 ) write ( x / 10 );
putchar ( x % 10 + '0' );
}
struct node {
ll number, cont;
} s[50005];
bool cmp1 ( node a, node b ) {
if ( a.number != b.number ) return a.number < b.number;
if ( a.cont < b.cont ) return true;
return false;
}
bool cmp2 ( node a, node b ) {
return a.cont < b.cont;
}
int main () {
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
cin >> T;
while ( T-- ) {
cin >> n;
for ( int i = 1; i <= n; i++ ) {
s[i].number = read(), s[i].cont = i;
}
sort ( s + 1, s + 1 + n, cmp1 );
for ( int i = 1; i <= n; i++ ) {
if ( s[i].number == s[i - 1].number ) s[i].cont = 50005;
}
sort ( s + 1, s + 1 + n, cmp2 );
for ( int i = 1; i <= n; i++ ) {
if ( s[i].cont == 50005 ) break;
write ( s[i].number );
putchar ( ' ' );
}
}
return 0;
}
```
by orgn @ 2022-04-08 22:12:54