QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#107361#5438. Half Mixedwarner1129WA 2ms3480kbC++202.2kb2023-05-21 03:41:202023-05-21 03:41:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-21 03:41:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3480kb
  • [2023-05-21 03:41:20]
  • 提交

answer

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>

using namespace std;
using namespace __gnu_pbds;

#ifdef LOCAL
void dbg() { cerr << '\n'; }
template<class T, class ...U> void dbg(T a, U ...b) { cerr << a << ' ', dbg(b...); }
template<class T> void org(T l, T r) { while (l != r) cerr << *l++ << ' '; cerr << '\n'; }
#define debug(args...) (dbg("(" + string(#args) + ") = (", args, ")"))
#define orange(args...) (cerr << "[" + string(#args) + ") = ", org(args))
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define debug(...) ((void)0)
#define orange(...) ((void)0)
#endif
template<class T> bool chmin(T &a, T b) { return b < a and (a = b, true); }
template<class T> bool chmax(T &a, T b) { return b > a and (a = b, true); }
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define ff first
#define ss second
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, double> pdd;

template<class T>
using BST = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

constexpr int INF = 1<<30;
constexpr long long mod = 998244353;

void solve() {
	long long n, m;
	cin >> n >> m;

	if (n * (n + 1) % 4 and m * (m + 1) % 4) {
		return void(cout << "No\n");
	}

	bool f = false;
	if (m * (m + 1) % 4) {
		f = true;
		swap(n, m);
	}

	long long res = m * (m - 1) / 2;
	vector<long long> seg{0};
	for (long long i = 1; i <= m; i++) {
		if ((i - seg.back()) * (i - seg.back()) + m - i > res) {
			i--;
			res -= (i - seg.back()) * (i - seg.back());
			seg.emplace_back(i);
		}
	}

	seg.emplace_back(m);
	string line;
	for (int i = 1; i < seg.size(); i++)
		line += string(seg[i] - seg[i - 1], '0' + i % 2);

	cout << "Yes\n";
	if (f) {
		for (int i = 0; i < m; i++)
			cout << string(n, line[i]) << '\n';
	}
	else {
		for (int i = 0; i < n; i++)
			cout << line << '\n';
	}

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

/*

2 3
2 5
3 4 1

6 6
1 1 4 5 1 4
1 1 4 5 1 4 

*/



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3480kb

input:

2
2 3
1 1

output:

Yes
101
101
No

result:

wrong answer Integer parameter [name=M[i][j]] equals to 101, violates the range [0, 1] (test case 1)