QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#608449#5438. Half MixedLittleYooCompile Error//C++201.1kb2024-10-03 21:59:592024-10-03 22:00:00

Judging History

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

  • [2024-10-03 22:00:00]
  • 评测
  • [2024-10-03 21:59:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
	int n, m;
	cin >> n >> m;
	if(n * m * (n + 1) * (m + 1) % 8 != 0) {
		cout << "No\n";
		return ;
	}
	cout << "Yes\n";
	bool horizon = 1;
	if(m * (m + 1) % 4 != 0) {
		swap(n, m);
		horizon = 0;
	}
	int tar = m * (m + 1) / 4 - m, cur = 0;
	vector<int> seg;


	while(rem) {
		int l = 1, r = m + 1;
		while(l < r - 1) {
			int mid = l + r >> 1;
			if(1ll * cur + mid * (mid + 1) / 2 <= tar)
				l = mid;
			else
				r = mid;
		}
		seg.emplace_back(l);
		rem -= l;
		cur += l * (l + 1) / 2;
	}
	string s;
	bool now = 0;
	for(auto &c : seg) {
		for(int i = 0; i < c; ++i)
			s += '0' + now;
		now ^= 1;
	}
	if(horizon) {
		for(int i = 0; i < n; ++i) {
			for(auto &c : s)
				cout << c << ' ';
			cout << '\n';
		}
	} else {
		for(auto &c : s) {
			for(int i = 0; i < n; ++i)
				cout << c << " \n"[i == n - 1];
		}
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	cin >> T;
	while(T--)
		solve();
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:22:15: error: ‘rem’ was not declared in this scope; did you mean ‘drem’?
   22 |         while(rem) {
      |               ^~~
      |               drem