哈希写得没问题,用的自己写的超级快读快写模板,超级快读测试过了没问题,但是一用超级快写(普通快写也会)就 WA,自己检查过了输入输出都没什么问题的,调了好久了,求大神指教!
#include <cstring>
#include <iostream>
using namespace std;
namespace IO
{
char inf[1 << 23], ouf[1 << 23], *p1 = inf, *p2 = inf, *p3 = ouf;
inline char input()
{
if (p1 == p2)
p2 = (p1 = inf) + fread(inf, 1, 1 << 23, stdin);
return *p1++;
}
template <typename R1> inline void read(R1 &x)
{
x = 0;
register short sign = 1;
register char ch = input();
while (!isdigit(ch))
{
if (ch == 45)
sign = -1;
ch = input();
}
while (isdigit(ch))
{
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = input();
}
x *= sign;
}
inline void text(const char ch)
{
*p3++ = ch;
}
inline void text(const string s)
{
memcpy(p3, s.data(), s.size()), p3 += s.size();
}
template <typename W1> inline void write(W1 x)
{
if (x < 0)
text(45), x = -x;
if (x > 9)
write(x / 10);
text(x % 10 ^ 48);
}
inline void flush()
{
fwrite(ouf, 1, p3 - ouf, stdout), p3 = ouf;
}
} // namespace IO
using IO::read, IO::text, IO::write, IO::flush;
const int N = 98299;
long long map[N];
inline bool find(const int x)
{
int k = (x % N + N) % N;
while (map[k % N] ^ x && map[k % N] ^ 0x3f3f3f3f3f3f3f3f)
k++;
if (map[k % N] ^ x)
return map[k % N] = x, 0;
return 1;
}
int main()
{
int t;
read(t);
while (t--)
{
int n;
read(n);
memset(map, 0x3f, sizeof map);
while (n--)
{
int tmp;
read(tmp);
if (!find(tmp))
write(tmp), text(' ');
}
text('\n');
flush();
}
return 0;
}