QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#698288 | #5438. Half Mixed | absabs | WA | 0ms | 3692kb | C++23 | 2.9kb | 2024-11-01 18:39:20 | 2024-11-01 18:39:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ull unsigned long long
#define ms(x, y) memset(x, y, sizeof x);
#define debug(x) cout << #x << " = " << x << endl;
#define ios ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define fre \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
const int mod = 998244353;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10;
const double esp = 1e-6;
const ull MOD1 = 1610612741;
const ull MOD2 = 805306457;
const ull BASE1 = 1331;
const ull BASE2 = 131;
#define pre(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
char *p1, *p2, buf[100000]; // 快读和同步流二者只能选一个
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
int read()
{
int x = 0, f = 1;
char ch = nc();
while (ch < 48 || ch > 57)
{
if (ch == '-')
f = -1;
ch = nc();
}
while (ch >= 48 && ch <= 57)
x = x * 10 + ch - 48, ch = nc();
return x * f;
}
void write(int x)
{
if (x < 0)
putchar('-'), x = -x;
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
return;
}
void solve()
{
int n,m;
cin>>n>>m;
if((n*(n-1))/2*(m*(m-1))/2%2==0){
cout<<"No"<<endl;
return;
}
int xx=(n*(n-1))/2*(m*(m-1))/2;
for(int i=1;i<=n;i++){
int sum=(m*(m-1)/2*((i+1)*i/2+n-i));
if(sum==xx){
cout<<"Yes"<<endl;
for(int j=1;j<=i;j++){
for(int x=1;x<=m;x++)cout<<1<<" ";
cout<<endl;
}
for(int j=i+1;j<=n;j++){
if((j%2)==(i%2)){
for(int x=1;x<=m;x++)cout<<1<<" ";
}
else for(int x=1;x<=m;x++){
cout<<0<<" ";
}
cout<<endl;
}
return;
}
}
for(int i=1;i<=m;i++){
int sum=(n*(n-1)/2*((i+1)*i/2+m-i));
if(sum==xx){
cout<<"Yes"<<endl;
for(int x=1;x<=n;x++){
for(int j=1;j<=i;j++)cout<<1<<" ";
for(int j=i+1;j<=m;j++){
if((j%2)==(i%2))cout<<1<<" ";
else cout<<0<<" ";
}
cout<<endl;
}
return;
}
}
cout<<"No"<<endl;
}
// #define LOCAL
signed main()
{
ios
// fre
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
auto start = std::chrono::high_resolution_clock::now();
#endif
int t = 1;
cin >> t;
while (t--)
solve();
#ifdef LOCAL
auto end = std::chrono::high_resolution_clock::now();
cout << "Execution time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
<< " ms" << '\n';
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3692kb
input:
2 2 3 1 1
output:
Yes 1 0 1 1 0 1 No
result:
ok OK, Accepted. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3680kb
input:
5382 1 1 1 2 2 1 1 3 2 2 3 1 1 4 2 3 3 2 4 1 1 5 2 4 3 3 4 2 5 1 1 6 2 5 3 4 4 3 5 2 6 1 1 7 2 6 3 5 4 4 5 3 6 2 7 1 1 8 2 7 3 6 4 5 5 4 6 3 7 2 8 1 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 9 1 1 10 2 9 3 8 4 7 5 6 6 5 7 4 8 3 9 2 10 1 1 11 2 10 3 9 4 8 5 7 6 6 7 5 8 4 9 3 10 2 11 1 1 12 2 11 3 10 4 9 5 8 6 ...
output:
No No No No No No No Yes 1 0 1 1 0 1 Yes 1 1 0 0 1 1 No No No Yes 1 1 1 0 0 0 1 1 1 No No No No No No No No No No No No No No No No No Yes 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 No No Yes 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 No No No No Yes 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 N...
result:
wrong answer Wrong Verdict (test case 4)