QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#419816#5438. Half Mixedxuanbac05WA 0ms3524kbC++141.6kb2024-05-24 11:35:192024-05-24 11:35:20

Judging History

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

  • [2024-05-24 11:35:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2024-05-24 11:35:19]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define endl '\n'
#define MASK(i) (1LL << (i))
#define ull unsigned long long
#define ld long double
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define BIT(x , i) ((x >> (i)) & 1)
#define TASK "task"
#define sz(s) (int) (s).size()
 
using namespace std;
const int mxN = 5e5 + 227;
const int inf = 1e9 + 277;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 7;
const int base = 307;
const int LOG = 20;
 
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}
 
int n;
int m;
 
void solve()
{
	cin >> n >> m;
	ll tot = 1LL * n * m * (n + 1) * (m + 1) / 4;
	if(tot % 2 != 0) cout << "NO" << endl;
	else {
		ll cur = 0;
		ll target = 1LL * m * (m + 1) / 4;
		vector<int> value;
		while(target > 0) {
			int lo = 1, hi = m - cur + 1;
			while(lo + 1 < hi) {
				int mid = (lo + hi) / 2;
				if(1LL * mid * (mid + 1) / 2 + m - (cur + mid) > target) hi = mid;
				else lo = mid;
			}
			target -= 1LL * lo * (lo + 1) / 2;
			cur += lo;
			value.pb(lo);
		}
		assert(target == 0 && cur == m);
		cout << "YES" << endl;
		for(int i = 1; i <= n; i++) {
			for(int j = 0; j < sz(value); j++) {
				for(int k = 0; k < value[j]; k++) cout << (j & 1) << ' ';
			}
			cout << endl;
		}

	}
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int tc = 1;
	cin >> tc;
	while(tc--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3
1 1

output:

YES
0 1 0 
0 1 0 
NO

result:

wrong answer Token "YES" doesn't correspond to pattern "Yes|No" (test case 1)