QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220001#6818. Barrel Theory1722087564WA 2ms3712kbC++143.1kb2023-10-19 20:36:242023-10-19 20:36:25

Judging History

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

  • [2023-10-19 20:36:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3712kb
  • [2023-10-19 20:36:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m;
int c[100];
void solve() {
	cin >> n >> m;
	if (n == 1) {
		cout << "NO\n";
		return ;
	}
	if (n == 2 && m % 2 == 0) {
		cout << "YES\n";
		cout << m / 2 << " " << m / 2 << "\n";
		return ;
	}
	if (n == 2) {
		bool  flag = false;
		for (int i = 0; i <= 20; i++) {
			if (m == (1 << i) - 1) flag = true;
		}
		if (flag) {
			cout << "NO\n";

		} else {
			cout << "YES\n";
			cout << m / 2 << " " << m / 2 + 1 << "\n";
		}
		return;
	}
	if (n == 3 && m % 2 == 0) {
		if(m==4||m==8) {
			cout<<"NO\n";
			return;
		}
		for(int i=4; i<=20; i++) {
			if(m==(1<<i)) {
				cout<<"YES\n";
				cout<<3<<" "<<(m-3)/2<<" "<<(m-3)/2+1<<"\n";
				return;
			}
		}
		for(int i=0; i<=20; i++) {
			if((m&(1<<i))&&(m>(1<<i))) {
				cout<<"YES\n";
				cout<<m/2<<" "<<m/2-(1<<i)<<" "<<(1<<i)<<"\n";
				return;
			}
		}

	}
	if (n == 3 && m % 2 == 1) {
		if(m==3||m==5||m==7||m==9||m==11||m==17||m==19) {
			cout<<"NO\n";
			return ;
		}
		if(m%8==5) {
			cout<<"YES\n";
			cout<<(m-5)/2<<" "<<(m-5)/2+2<<" "<<3<<"\n";
			return ;
		}
		if(m%8==7) {
			cout<<"YES\n";
			cout<<(m-7)/2+1<<" "<<(m-7)/2+3<<" "<<3<<"\n";
			return ;
		}
		if(m%16==9) {
			cout<<"YES\n";
			cout<<(m-9)/2<<" "<<(m-9)/2+4<<" "<<5<<"\n";
			return ;
		}
		if(m%16==11) {
			cout<<"YES\n";
			cout<<(m-11)/2+1<<" "<<(m-11)/2+5<<" "<<5<<"\n";
			return ;
		}
		if(m%16==1) {
			cout<<"YES\n";
			cout<<(m-17)/2+3<<" "<<(m-17)/2+7<<" "<<7<<"\n";
			return ;
		}
		if(m%16==3) {
			cout<<"YES\n";
			cout<<(m-19)/2+5<<" "<<(m-19)/2+7<<" "<<7<<"\n";
			return ;
		}
		cout<<"NO\n";
		return ;
	}


	if (n % 2 == 0 && m % 2 == 0) {
		cout << "YES\n";
		for (int i = 1; i <= n - 2; i++) {
			cout << 1 << " ";
			m--;
		}
		cout << m / 2 << " " << m / 2 << "\n";

	}
	if (n % 2 == 0 && m % 2 == 1) {
		if (m >= 2 * (n - 2) + 5) {
			cout << "YES\n";
			cout << 2 << " " << 3 << " ";
			m -= 5;
			for (int i = 1; i <= n - 4; i++) {
				cout << 2 << " ";
				m -= 2;
			}
			if (n - 2 <= 0) {
				cout << "\n";
				return;
			}
			cout << m / 2 << " " << m / 2 << "\n";
		} else cout << "NO\n";
	}
	if (n % 2 == 1 && m % 2 == 0) {
		if (m >= 6 + n - 3) {
			cout << "YES\n";
			cout << 1 << " " << 2 << " " << 3 << " ";
			m -= 6;
			for (int i = 1; i <= n - 3 - 2; i++) {
				cout << 1 << " ";
				m--;
			}
			if (n - 3 <= 0) {
				cout << "\n";
				return;
			}
			cout << m / 2 << " " << m / 2 << "\n";
		} else cout << "NO\n";

	}
	if (n % 2 == 1 && m % 2 == 1) {
		if (m >= 2 * (n - 3) + 13) {
			cout << "YES\n";
			cout << 2 << " " << 4 << " " << 7 << " ";
			m -= 13;
			for (int i = 1; i <= n - 3 - 2; i++) {
				cout << 2 << " ";
				m -= 2;
			}
			if (n - 3 <= 0) {
				cout << "\n";
				return;
			}
			cout << m / 2 << " " << m / 2 << "\n";
		} else cout << "NO\n";
	}
}
signed main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int T = 1;
	cin >> T;

	for(int T0=1; T0<=T; T0++) {
		if(T0==947) cout<<m<<" ";
		solve();
	}




	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

3
6 7
5 17
4 4

output:

NO
YES
2 4 7 2 2
YES
1 1 1 1

result:

ok T=3 (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3660kb

input:

4194
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

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