QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709887 | #5465. Maximum GCD | 123456zmy# | RE | 0ms | 0kb | C++17 | 1.3kb | 2024-11-04 17:19:01 | 2024-11-04 17:19:05 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve()
{
int n, m;
cin >> n >> m;
bool f = 0;
if (n % 2) {
swap(n, m);
f = 1;
}
if (n * m % 2) {
cout << "NO\n";
return;
}
int mn = min(n, m), mx = min(n, m);
if (mn <= 10 && pow(2, mn) < mx) {
cout << "NO\n";
return;
}
cout << "YES\n";
vector<vector<int>> v;
for (int i = 0; i < m / 2; i++) {
vector<int> t1(n), t2(n);
for (int j = 0; j < n; j++) {
if (j <= 10) t1[j] = (i >> j) & 1;
else break;
}
for (int j = 0; j < n; j++) {
t2[j] = 1 - t1[j];
}
v.push_back(t1);
v.push_back(t2);
}
if (m % 2) {
vector<int> t;
for (int i = 0; i < n / 2; i++)
t[i] = 1;
v.push_back(t);
}
sort(v.begin(), v.end());
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout << v[i][j];
}
cout << endl;
}
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
solve();
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
3 3 10 7