QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#479906 | #4617. Arithmetic Subsequence | masterhuang | WA | 13ms | 3600kb | C++20 | 927b | 2024-07-15 21:52:10 | 2024-07-15 21:52:10 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=5005;
int T,n;bool ok;
unordered_map<int,int>c;
struct node{int x,y;}a[N];
inline void sol(int l,int r)
{
if(l==r||!ok) return;
sort(a+l,a+1+r,[](node x,node y){return (x.x&1)<(y.x&1);});
if((a[l].x&1)==(a[r].x&1))
{
for(int i=l;i<=r;i++) c[a[l].x]++;
for(auto [x,y]:c) if(y>2){ok=0;break;}
for(int i=l;i<=r;i++) c[a[l].x]--;return;
}
for(int w=l;w<=r;w++) if((a[w].x^a[w+1].x)&1)
{
for(int i=l;i<=r;i++) a[i].x>>=1;
return sol(l,w),sol(w+1,r);
}
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>T;
while(T--)
{
cin>>n;ok=1;
for(int i=1;i<=n;i++) cin>>a[i].x,a[i].y=a[i].x;
sol(1,n);if(!ok){cout<<"NO\n";continue;}cout<<"YES\n";
for(int i=1;i<=n;i++) cout<<a[i].y<<" ";cout<<"\n";
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 13ms
memory: 3600kb
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 8 6 9 3 NO NO NO NO NO NO NO NO NO YES 4096 2048 1024 3072 512 4608 2560 1536 3584 256 4352 2304 1280 3328 768 4864 2816 1792 3840 128 4224 2176 1152 3200 640 4736 2688 1664 3712 384 4480 2432 1408 3456 896 4992 2944 1920 3968 64 4160 2112 1088 3136 576 4672 2624 1600 3648 320 4416 2368 1344 33...
result:
wrong answer