QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534491#5438. Half MixedSound_MediumWA 0ms3620kbC++231.9kb2024-08-27 12:00:112024-08-27 12:00:11

Judging History

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

  • [2024-08-27 12:00:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-08-27 12:00:11]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m;

void solve () {
    cin>>n>>m;
    int v1=n*(n+1)/2,v2=m*(m+1)/2;
    if(v1%2==1&&v2%2==1){
        cout<<"No\n";
        return ;
    }   
    vector ans(n,vector<int>(m));
    if(v1%2==0){
        int r1=n*(n+1)/4,r2=n;
        vector<int>len;
        while(1){
            int l=1,r=n;
            while(l<r){
                int mid=l+r+1>>1;
                if(mid*(mid+1)/2+r2-mid<=r1){
                    l=mid;
                }
                else r=mid-1;
            }
            r1-=l*(l+1)/2,r2=r2-l;
            len.push_back(l);
            if(r1==0)break;
        }
        int v=1;
        vector<int>a;
        for(int i=0;i<len.size();i++){
            for(int j=1;j<=len[i];j++){
                a.push_back(v);
            }
            v^=1;
        }
        cout<<"Yes\n";
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cout<<a[i-1]<<" ";
            }
            cout<<"\n";
        }
        return ;
    }
    int r1=m*(m+1)/4,r2=m;
    vector<int>len;
    while(1){
        int l=1,r=r2;
        while(l<r){
            int mid=l+r+1>>1;
            if(mid*(mid+1)/2+r2-mid<=r1)l=mid;
            else r=mid-1;
        }
        r2-=l,r1-=l*(l+1)/2;
        len.push_back(l);
        if(r1==0)break;
    }   
    vector<int>a;
        int v=1;
        for(int i=0;i<len.size();i++){
            for(int j=1;j<=len[i];j++){
                a.push_back(v);
            }
            v^=1;
        }
        cout<<"Yes\n";
        for(int i=1;i<=n;i++){
            for(auto v:a){
                cout<<v<<" ";
            }
            cout<<"\n";
        }
}
signed main () {
    int T = 1; 
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // cin>>T;
    while (T --) solve ();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

2
2 3
1 1

output:

No

result:

wrong answer Wrong Verdict (test case 1)