QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695632#5438. Half MixedxzinRE 0ms0kbC++141.3kb2024-10-31 20:29:152024-10-31 20:29:27

Judging History

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

  • [2024-10-31 20:29:27]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-31 20:29:15]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

#define N 1010000
using ll  = long long;


int n, m;
long long f[N];
int v[N];
int ck(ll k) {
    int p = 1, oe = 1;
    for(int i = max(n, m);i >= 2; i--) {
        while (k >= f[i]) {
            k -= f[i];
            for(int j = p; j <= p + i - 1; j++)
                v[j] = oe; 
            oe ^= 1;  p += i;
        }
    }
    for(int i = p; i <= max(n, m); i++) {
        v[i] = oe; oe ^= 1;
    }
}
void sl() {
    cin>>n>>m; 
    for(int i = 1;i <= max(n, m); i++) v[i] = 0;
    if(n % 4 == 0 || n % 4 == 3) {
        cout<<"Yes\n";
        int k = ck(1ll * n * (n + 1) / 4 - n);
        for(int i = 1;i <= n; i++) {
            for(int j = 1; j <= m; j++) 
                cout<<v[i]<<" ";
            cout<<'\n';
        }
    }
    else if(m % 4 == 0 || m % 4 == 3) {
        cout<<"Yes\n";
        int k = ck(1ll * m * (m + 1) / 4 - m); 
        for(int i = 1;i <= n; i++) {
            for(int j = 1; j <= m; j++) 
                cout<<v[j]<<" ";
            cout<<'\n';
        }
    }
    else cout<<"No"<<endl;
}
int main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);  
    for(int i = 2;i <= 1000000; i++) {
        f[i] = i * (i  - 1) / 2;
    }
    int T; cin>>T;
    while (T--)  sl();
    
    return 0;

}
/*
*/

詳細信息

Test #1:

score: 0
Runtime Error

input:

2
2 3
1 1

output:


result: