QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#664142 | #5438. Half Mixed | Yurily | WA | 1ms | 3740kb | C++20 | 1.7kb | 2024-10-21 19:22:08 | 2024-10-21 19:22:13 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAX=1e6+5;
int n,m;
vector<int> ans[MAX];
void solve(){
cin>>n>>m;
int k=(1+n)*n/2*(1+m)*m/2;
for(int i=1;i<=n;++i){
ans[i].clear();
for(int j=1;j<=m+1;++j)
ans[i].push_back(0);
}
if(k&1){
printf("No\n");
return;
}
if(m%4==0||(1+m)%4==0){
bool flag=0;
int cur=0,now=0,len=0,k=(1+m)*m/4;
while(cur<=m){
cur++,len++;
ans[1][cur]=now;
// cout<<cur<<endl;
if((1+len)*len/2+m-cur>k){
// cout<<cur<<endl;
cur--;
len--;
if(len>=1){
k-=(1+len)*len/2;
len=0;
now^=1;
}
else
break;
}
if(k==0&&cur==m){
flag=1;
break;
}
if(k==0)
break;
}
if(flag){
for(int i=2;i<=n;++i){
for(int j=1;j<=m;++j)
ans[i][j]=ans[i-1][j]^1;
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j)
printf("%d ",ans[i][j]);
printf("\n");
}
return;
}
}
if(n%4==0||(1+n)%4==0){
bool flag=0;
int cur=0,now=0,len=0,k=(1+n)*n/2;
while(cur<=n){
cur++,len++;
ans[cur][1]=now;
if((1+len)*len/2+n-cur>k){
cur--;
len--;
if(len>=1){
k-=(1+len)*len/2;
len=0;
now^=1;
}
else
break;
}
if(k==0&&cur==n){
flag=1;
break;
}
if(k==0)
break;
}
if(flag){
for(int j=2;j<=m;++j){
for(int i=1;i<=n;++i)
ans[i][j]=ans[i][j-1]^1;
}
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j)
printf("%d ",ans[i][j]);
printf("\n");
}
return;
}
}
printf("No\n");
}
signed main(){
int T;
cin>>T;
while(T--){
solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3740kb
input:
2 2 3 1 1
output:
0 1 0 1 0 1 No
result:
wrong answer Token "0" doesn't correspond to pattern "Yes|No" (test case 1)