QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#479911#4617. Arithmetic SubsequencemasterhuangWA 22ms4028kbC++20856b2024-07-15 21:55:182024-07-15 21:55:19

Judging History

你现在查看的是最新测评结果

  • [2024-07-15 21:55:19]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:4028kb
  • [2024-07-15 21:55:18]
  • 提交

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;unordered_map<int,int>c;
struct node{int x,y;}a[N];
inline void sol(int l,int r)
{
	if(l==r) 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)) 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;bool ok=1;c.clear();
		for(int i=1;i<=n;i++) cin>>a[i].x,a[i].y=a[i].x,c[a[i].x]++;
		for(auto [x,y]:c) if(y>2){ok=0;break;}
		if(!ok){cout<<"NO\n";continue;}sol(1,n);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: 22ms
memory: 4028kb

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
YES
582103040 257054720 720724992 786444800 1815040 100567552 144378368 361720320 575314432 332195328 89164032 558150912 122244352 685571328 674378496 39983872 580401920 4005632 972075136 125479040 951912576 327248512 62466688 459315840 250903168 570091136 813373056 204869248 3118731...

result:

wrong answer