QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#790068 | #5438. Half Mixed | myloveATRI | WA | 0ms | 3712kb | C++20 | 1.7kb | 2024-11-28 00:26:53 | 2024-11-28 00:26:53 |
Judging History
answer
#include<bits/stdc++.h>
#include<queue>
#include<string.h>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#define int long long
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nl t[n].l
#define nr t[n].r
#define gcd __gcd
#define itn int
//#define db long double
using namespace std;
const int maxn=1e6+50;
const int inf=1e18+10;
const int INF=2e18;
const int mod=998244353;
//const db eps=1e-8;
//const db pi=acos(-1.0);
#define pop_count __builtin_popcountll
int a[maxn];
void solve()
{
int n,m;
cin>>m>>n;
int tot=(n*(n+1)/2)*(m*(m+1)/2);
if(tot%2==1)
{
cout<<"-1\n";
return;
}
int f=0;
if((n*(n+1))%4!=0)
{
f=1;
swap(n,m);
}
int sum=n*(n+1)/4;
int now=0;
int id=1;
int typ=1;
//n-(id+mid-1)
while(id<=n)
{
int l=1,r=n-id+1;
int res;
while(l<=r)
{
int mid=l+r>>1;
if(now+mid*(mid+1)/2+n-id-mid+1<=n)
{
l=mid+1;
res=mid;
}
else r=mid-1;
}
now+=res*(res+1)/2;
while(res--)
{
a[id]=typ;
id++;
}
typ^=1;
}
if(f==0)
{
rep(i,1,m)
{
rep(j,1,n) cout<<a[j]<<' ';
cout<<'\n';
}
}
else{
rep(i,1,n)
{
rep(j,1,m) cout<<a[i]<<' ';
cout<<'\n';
}
}
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int __=1;
//srand((time(0)));
cin>>__;
while(__--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3712kb
input:
2 2 3 1 1
output:
1 0 1 1 0 1 -1
result:
wrong answer Token "1" doesn't correspond to pattern "Yes|No" (test case 1)