QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153380#6818. Barrel TheorylinninsWA 0ms1732kbC++145.6kb2023-08-29 23:38:322023-08-29 23:38:33

Judging History

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

  • [2023-08-29 23:38:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1732kb
  • [2023-08-29 23:38:32]
  • 提交

answer

	#include<cstdio>
	
	using namespace std;
	
	int Ans[100500];
	
	int lowbit(int n)
	{
		return (n)&(-1*n);
	}
	
	int main()
	{
	//	freopen("k2.out","w",stdout);
	//	freopen("data.txt","r",stdin);
		int T;
		scanf("%d",&T);
		for(int i=1;i<=T;i++)
		{
			long long n,m;
			scanf("%lld%lld",&n,&m);
			if(n == m)
			{
				printf("YES");
				for(int i=1;i<=n;i++)
					printf("1 ");
				printf("\n");
				continue;
			}
//			if(T == 4194)
//			{
//				if(i != 1893)
//					continue;
//				else
//					printf("%d %d",n,m);
//			} 
			for(int i=1;i<=n;i++)
			{
				Ans[i] = 0;
			}
			if(m<n or n == 1)
			{
				printf("NO\n");
				continue;
			}
			if(n == 2)
			{
				if(((m/2)^(m/2+m%2)) >= m/2)
				{
					printf("NO\n");
					continue;
				}
				printf("YES\n");
				printf("%d %d\n",m/2,m/2+m%2);
				continue;
			}
			if(n == 3)
			{
				if(m%2 == 0)
				{
					if(lowbit(m) == m)
					{
						if(m<=8)
						{
							printf("NO\n");
							continue;
						}
						else
						{
							printf("YES\n"); 
							printf("%d %d %d\n",3*m/16,7*m/16,6*m/16);
							continue;
						}
					}
					else
					{
						printf("YES\n");
						printf("%d %d %d\n",lowbit(m)/2,m/2,m/2-lowbit(m)/2);
						continue;
					}
				}
				else
				{
					if(lowbit(m-1) == m-1)
					{
						if(m<=17)
						{
							printf("NO\n");
							continue;
						}
						else
						{
							printf("YES\n");
							printf("%d %d %d\n",3*m/16,6*m/16+1,7*m/16);
							continue;
						}
					}
					else if(lowbit(m-3) == m-3)
					{
						if(m<=19)
						{
							printf("NO\n");
							continue;
						}
						else
						{
							printf("YES\n");
							printf("%d %d %d\n",7,(m-7)/2-1,(m-7)/2+1);
							continue;
						}
					}
					else
					{
						if(m == 13)
						{
							printf("YES\n");
							printf("3 4 6\n");
							continue;
						}
						else if(m == 15)
						{
							printf("YES\n");
							printf("3 5 7\n");
							continue;
						}
						else if(m <= 19)
						{
							printf("NO\n");
							continue;
						}
						else
						{
							if(m%8 == 5)
							{
								printf("YES\n"); 
								printf("%d %d %d\n",(m-5)/2,(m-5)/2+2,3);
							}
							else if(m%8 == 7)
							{
								printf("YES\n");
								printf("%d %d %d\n",(m-5)/2,(m-5)/2+2,3);
							}
							else if(m%16 == 1)
							{
								int t = 17,a = 3,b = 7, c = 7;
								printf("YES\n");
								printf("%d %d %d\n",(m-t)/2+a,(m-t)/2+b,c);
							}
							else if(m%16 == 3)
							{
								int t = 19,a = 5,b = 7, c = 7;
								printf("YES\n");
								printf("%d %d %d\n",(m-t)/2+a,(m-t)/2+b,c);
							}
							else if(m%16 == 9)
							{
								int t = 9,a = 0,b = 4, c = 5;
								printf("YES\n");
								printf("%d %d %d\n",(m-t)/2+a,(m-t)/2+b,c);
							}
							else if(m%16 == 11)
							{
								int t = 11,a = 1,b = 5, c = 5;
								printf("YES\n");
								printf("%d %d %d\n",(m-t)/2+a,(m-t)/2+b,c);
							}
							continue;
						}
					}
				}
			}
			else if(n%2 == 0)
			{
				if(m%2 == 0)
				{
					for(int i=1;i<=n-2;i++)
						Ans[i] = 1;
					Ans[n-1] = (m-(n-2))/2;
					Ans[n]   = (m-(n-2))/2;
				}
				else
				{
					if(2*n+1>m)
					{
						printf("NO\n");
						continue;
					}
					else
					/*
					4 11
					2 2 x x 7
					*/
					{
						for(int i=1;i<=n-2;i++)
							Ans[i] = 2;
						Ans[1] += 1;
						m -= (n-2)*2+1;
						if(m<=3)
						{
							printf("NO\n");
							continue;
						}
						else
						{
							Ans[n-1] = m/2;
							Ans[n] = m/2 + m%2;
						}
					}
				}
			}
			else//n是奇数 
			{
				if(m%2==0)//m是偶数
				{
					for(int i=1;i<=n-3;i++)
						Ans[i] = 1;
					m -= (n-3);
					if(m<=5)
					{
						printf("NO\n");
						continue;
					}
					else
					{
						if(m == lowbit(m))
						{
							if(m <=4)
							{
								printf("NO\n");
								continue;
							}
							else
							{
								Ans[1] = 2;
								Ans[2] = 2;
								m-=2;
								Ans[n-2] = lowbit(m)/2;
								Ans[n-1] = (m-lowbit(m))/2+lowbit(m)/2;
								Ans[n]   = (m-lowbit(m))/2;
							} 
						}
						else
						{
							Ans[n-2] = lowbit(m)/2;
							Ans[n-1] = (m-lowbit(m))/2+lowbit(m)/2;
							Ans[n]   = (m-lowbit(m))/2;
						}
					}
					
				}
				else//m是奇数
				{
					if(n*2+1>m) 
					{
						printf("NO\n");
						continue;
					}
					else
					{
						for(int i=1;i<=n-3;i++)
						{
							Ans[i] = 2;
						}
						Ans[1] = 3;
						m -= (n-3)*2+1;
						if(lowbit(m) == 2 and lowbit(m-2) == m-2)
						{
							Ans[1] += 2;
							Ans[2] += 2;
							m -= 4;
							//  5 4 2 2 2 x x x 6 2 4  12 1 1 0 0 
							
						}
						if(m == lowbit(m))
						{
							if(m <= 8)
							{
								printf("NO\n");
								continue;
							}
							else
							{
								Ans[1] = 5;
								Ans[2] = 4; 
								m = m-4;
								Ans[n-2] = lowbit(m)/2;
								Ans[n-1] = m/2-lowbit(m)/2;
								Ans[n]   = m/2;
							}
						}
						else if(lowbit(m) == 2)
						{
							if(m<=10)
							{
								printf("NO\n");
								continue;
							}
							else
							{
								Ans[1] = 3;
								Ans[2] = 3;
								m -= 2;
								Ans[n-2] = lowbit(m)/2;
								Ans[n-1] = m/2 - lowbit(m)/2+1;
								Ans[n]   = m/2;
							}
							
						}
						else
						{
							Ans[n-2] = lowbit(m)/2;
							Ans[n-1] = m/2-lowbit(m)/2;
							Ans[n] = m/2;
						}
					}
				}
			}
			printf("YES\n");
			for(int i=1;i<=n;i++)
			{
				printf("%d ",Ans[i]);
			}
			printf("\n");
		}
		return 0;
	}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1732kb

input:

3
6 7
5 17
4 4

output:

NO
YES
3 2 2 4 6 
YES1 1 1 1 

result:

wrong answer Token parameter [name=ans] equals to "YES1", doesn't correspond to pattern "(YES)|(NO)" (test case 3)