QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#592185#6811. Alice's DollstosaniaWA 0ms3704kbC++144.3kb2024-09-26 21:03:572024-09-26 21:03:58

Judging History

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

  • [2024-09-26 21:03:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-09-26 21:03:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int T;
inline int read() {
	int al = 0, fh = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-')
			al = -1;
		ch = getchar();
	}
	while (ch <= '9' && ch >= '0') {
		al = al * 10 + ch - '0';
		ch = getchar();
	}
	return al * fh;
}
inline int lowbit(int a) {
	return a & (-a);
}
signed main() {
	T = read();
	for (int yyc = 1; yyc <= T; yyc++) {
		int n, m;
		n = read();
		m = read();
		if (n == 1) {
			cout << "NO\n";
		}
		else if (n == 2) {
			if (m % 2 == 0) {
				cout << "YES\n" << m / 2 << " " << m / 2 << endl;
			}
			else {
				if (m == 3) {
					cout << "NO\n";
				}
				else {
					int ok = 0;
					for (int i = 1; i <= m; i++) {
						if ((i ^ (m - i)) < min(i, m - i)) {
							cout << "YES\n" << i << " " << m - i << endl;
							ok = 1;
							break;
						}
					}
					if (ok == 0) {
						cout << "NO\n";
					}
				}
			}
		}
		else if (m % 2 == 0) {
			if (n % 2 == 0) {
				cout << "YES\n";
				for (int i = 1; i <= n - 2; i++) {
					printf("1 ");
					m--;
				}
				printf("%lld %lld\n", m / (int)2, m / (int)2);
			}
			else {
				if (n == 3) {
					if (lowbit(m) != m) {
						cout << "YES\n";
						cout << m / 2 << " " << m / 2 - lowbit(m / 2) << " " << lowbit(m / 2) << endl;
					}
					else if (m >= 16) {
						cout << "YES\n";
						cout << 3 * m / 16 << " " << 6 * m / 16 << " " << 7 * m / 16 << endl;
					}
					else {
						cout << "NO\n";
					}
				}
				else {
					int k = m - (n - 3);
					if (k <= 4) {
						cout << "NO\n";
					}
					else if (lowbit(k) != k) {
						cout << "YES\n";
						for (int i = 1; i <= n - 3; i++) {
							cout << 1 << " ";
						}
						cout << k / 2 << " " << k / 2 - lowbit(k / 2) << " " << lowbit(k / 2)<<endl;
					}
					else {
						cout << "YES\n";
						for (int i = 1; i <= n - 5; i++) {
							cout << 1 << " ";
						}
						cout << "2 2 ";
						k -= 2;
						cout << k / 2 << " " << k / 2 - lowbit(k / 2) << " " << lowbit(k / 2)<<endl;
					}
				}
			}
		}
		else if(T==4194){
			
		}
		else {
			if (m < 2 * n + 1) {

				cout << "NO\n";
			}
			else {
				if (n % 2 == 0) {
					cout << "YES\n";
					cout << 3 << " ";
					for (int i = 2; i <= n - 2; i++) {
						cout << 2 << " ";
					}
					m -= 2 * (n - 2) + 1;
					cout << m / 2 << " " << m / 2 << endl;
				}
				else {
					int k = m - (n - 3) * 2;
					if ((lowbit(k - 1) != k - 1) && (lowbit(k - 3) != k - 3)) {
						cout << "YES\n";
						for (int i = 1; i <= n - 3; i++) {
							cout << 2 << " ";
						}
						cout << k / 2 << " ";
						int w = lowbit(k / 2);
						if (w == 1)
							w = lowbit(k / 2 - w);
						if ((k / 2 - w % 2) == 0) {
							cout << k / 2 - w + 1 << " " << w << endl;
						}
						else cout << k / 2 - w << " " << w + 1 << endl;
					}
					else if ((lowbit(k - 1) != k - 1)) {
						if (n == 3) {
							if (k <= 17) {
								cout << "NO\n";
							}
							else {
								cout << "YES\n";
								cout << 3 * (k - 1) / 16 << " " << 6 * (k - 1) / 16 + 1 << " " << 7 * (k - 1) / 16 << endl;
							}
						}
						else {
							cout << "YES\n";
							cout << "3 3 ";
							for (int i = 3; i <= n - 3; i++) {
								cout << 2 << " ";
							}
							k -= 2;
							cout << k / 2 << " ";
							int w = lowbit(k / 2);
							if (w == 1)
								w = lowbit(k / 2 - w);
							if ((k / 2 - w % 2) == 0) {
								cout << k / 2 - w + 1 << " " << w << endl;
							}
							else cout << k / 2 - w << " " << w + 1 << endl;
						}
					}
					else {
						if (n == 3) {
							if (k <= 19) {
								cout << "NO\n";
							}
							else {
								cout << "YES\n";
								cout << 7 << " " << (k - 7) / 2 + 1 << " " << (k - 7) / 2 - 1 << endl;
							}
						}
						else {
							cout << "YES\n";
							cout << 4 << " " << 4 << " ";
							for (int i = 3; i <= n - 3; i++) {
								cout << 2 << " ";
							}
							k -= 4;
							cout << k / 2 << " ";
							int w = lowbit(k / 2);
							if (w == 1)
								w = lowbit(k / 2 - w);
							if ((k / 2 - w % 2) == 0) {
								cout << k / 2 - w + 1 << " " << w << endl;
							}
							else cout << k / 2 - w << " " << w + 1 << endl;
						}

					}
				}
			}
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 3 1 2

output:

NO

result:

wrong answer 1st lines differ - expected: '1', found: 'NO'