QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790075#5438. Half MixedmyloveATRIWA 0ms3620kbC++201.8kb2024-11-28 00:33:312024-11-28 00:33:31

Judging History

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

  • [2024-11-28 00:33:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-28 00:33:31]
  • 提交

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<<"No\n";
        return;
    }
    int f=0;
    cout<<"Yes\n";
    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<=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: 3620kb

input:

2
2 3
1 1

output:

Yes
1 1 0 
1 1 0 
No

result:

wrong answer 6 Mixed Submatrices Found, but 9 Expected (test case 1)