QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#181244#5438. Half Mixedysghwzp#WA 1ms3456kbC++141.2kb2023-09-16 17:05:282023-09-16 17:05:28

Judging History

你现在查看的是最新测评结果

  • [2023-09-16 17:05:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3456kb
  • [2023-09-16 17:05:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int T,n,m;
vector<int>ans,pans;
bool solve(int n,long long m){
    if(m<n)return 0;
    if(m==n){
        for(int i=0;i<n;++i)
            ans.push_back(1);
        return 1;
    }
    //x*x+(n-x)*(n-x) >= m
    int u=sqrt(m);
    while((long long)u*u+(long long)(n-u)*(n-u)<=m)++u;
    for(int i=u;i>=1;--i){
        ans.push_back(i);
        if(solve(n-i,m-(long long)i*i))
            return 1;
        ans.pop_back();
    }
    return 0;
}

void work(int n,int m,int flag=0){
    int z=flag?m:n;
    ans.clear();
    solve(z,(long long)z*(z-1)/2);
    int op=1;
    pans.clear();
    for(int i:ans){
        op^=1;
        for(int j=0;j<i;++j)
            pans.push_back(op);
    }
    cout<<"YES\n";
    for(int i=0;i<n;++i)
        for(int j=0;j<m;++j)
            cout<<pans[flag?j:i]<<" \n"[j==m-1];

}

int main(){
    ios::sync_with_stdio(0);
    for(cin>>T;T --> 0;){
        cin>>n>>m;
        int s=0;
        if(n%4==3||n%4==0)
            work(n,m);
        else
        if(m%4==3||m%4==0)
            work(n,m,1);
        else{
            cout<<"NO"<<endl;
            continue;
        }

    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3456kb

input:

2
2 3
1 1

output:

YES
0 1 0
0 1 0
NO

result:

wrong answer Token "YES" doesn't correspond to pattern "Yes|No" (test case 1)