QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#64942 | #4617. Arithmetic Subsequence | qinjianbin | TL | 0ms | 0kb | C++17 | 735b | 2022-11-25 22:25:00 | 2022-11-25 22:25:02 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define _for(i, a, b) for(int i = (a); i <= (b); i++)
using namespace std;
const int N = 5e3 + 10;
unordered_map<int, int> mp;
int a[N], n;
bool cmp(int x, int y)
{
_for(j, 0, 30)
{
int tx = (x >> j) & 1, ty = (y >> j) & 1;
if(tx != ty) return tx > ty;
}
}
int main()
{
int T; scanf("%d", &T);
while(T--)
{
mp.clear();
scanf("%d", &n);
int flag = 1;
_for(i, 1, n)
{
scanf("%d", &a[i]);
if(++mp[a[i]] >= 3) flag = 0;
}
if(!flag)
{
puts("NO");
continue;
}
puts("YES");
sort(a + 1, a + n + 1, cmp);
_for(i, 1, n) printf("%d ", a[i]);
puts("");
}
return 0;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
25 4 3 6 8 9 5 1 1 1 1 1 5000 204869248 184063453 335277313 805198752 988635160 266844506 494544568 842685418 516257494 110006739 727397507 931812983 898605116 670474885 536302721 818724782 251547299 883494814 479828194 573135914 408419766 283100869 472145517 996777784 393702645 555881361 835407611 ...
output:
YES 3 9 6 8 NO YES 997457919 28540927 168284159 392485887 30561279 618477055 33609215 425276159 80450303 766389503 20466943 937493759 234127231 266813311 315469695 642043775 876816255 905333631 953092479 284389759 786805119 126109311 668253311 907828351 548105343 857108607 187678847 689291391 92700...