QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#769494 | #5438. Half Mixed | False0099# | WA | 0ms | 3480kb | C++20 | 2.6kb | 2024-11-21 17:54:56 | 2024-11-21 17:54:56 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
typedef pair<int, int> PII;
void init()
{
}
void solve()
{
int n, m;
cin >> n >> m;
bool flag = 1;
if (n > m)
{
flag = 0;
swap(n, m);
}
if (n * (n + 1) * m * (m + 1) % 8 != 0)
{
cout << "No" << endl;
return;
}
int need = n * (n + 1) * m * (m + 1) / 8;
for (int i = 1; i <= m; i++)
{
for (int j = i; j <= m; j++)
{
int tot = 0;
int len_left = (i - 1 - 1 + 1);
int len_mid = (j - i + 1);
int len_right = (m - (j + 1) + 1);
tot += len_left * (len_left + 1) * n * (n + 1) / 4;
tot += len_mid * (len_mid + 1) * n * (n + 1) / 4;
tot += len_right * (len_right + 1) * n * (n + 1) / 4;
// cout << i << " " << j << " " << tot << endl;
if (tot == need)
{
// cout<<i<<" "<<j<<endl;
cout << "YES" << endl;
vector<vector<int>> g(n + 1, vector<int>(m + 1));
for (int _ = 1; _ <= n; _++)
{
for (int __ = 1; __ <= i - 1; __++)
{
g[_][__] = 1;
}
for (int __ = i; __ <= j; __++)
{
g[_][__] = 0;
}
for (int __ = j + 1; __ <= m; __++)
{
g[_][__] = 1;
}
}
if (flag == 0)
{
for (int _ = 1; _ <= m; _++)
{
for (int __ = 1; __ <= n; __++)
{
cout << g[_][__] << " ";
}
cout << endl;
}
}
else
{
for (int _ = 1; _ <= n; _++)
{
for (int __ = 1; __ <= m; __++)
{
cout << g[_][__] << " ";
}
cout << endl;
}
}
return;
}
}
}
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0);
int t;
t = 1;
cin >> t;
init();
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3480kb
input:
2 2 3 1 1
output:
YES 1 0 1 1 0 1 No
result:
wrong answer Token "YES" doesn't correspond to pattern "Yes|No" (test case 1)