QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#766488#5438. Half MixedYue_chenWA 3ms10740kbC++172.0kb2024-11-20 17:29:562024-11-20 17:30:02

Judging History

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

  • [2024-11-20 17:30:02]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:10740kb
  • [2024-11-20 17:29:56]
  • 提交

answer

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

using i64 = long long;

vector<i64> f(1000001);

void solve() {
    int n, m; cin>>n>>m;
    
    if(n%4 == 3 or n%4 == 0) {
        int sum = 0;
        i64 x = f[n+1]/2 - n;
        vector<int> ans;
        while(x) {
            auto it = upper_bound(f.begin()+1, f.end(), x);
            it--;
            ans.push_back(it - f.begin());
            sum += it - f.begin();
            x -= *it;
        }
        
        while(sum < n) {
            ans.push_back(1);
            sum++;
        }
        
        int t = 0, now = 0;
        vector<int> res(n+1);
        for(auto x: ans) {
            for(int i=1; i<=x; ++i) {
                res[++now] = t;
            }
            t ^= 1;
        }
        
        cout<<"YES\n";
        for(int i=1; i<=n; ++i) {
            for(int j=1; j<=m; ++j) {
                cout<<res[i]<<" \n"[j==m];
            }
        }
        return ;
    }
    if(m%4 == 3 or m%4 == 0) {
        i64 x = f[m+1]/2 - m;
        int sum = 0;
        vector<int> ans;
        while(x) {
            auto it = upper_bound(f.begin()+1, f.end(), x);
            it--;
            ans.push_back(it - f.begin());
            sum += it - f.begin();
            x -= *it;
        }
        
        while(sum < m) {
            ans.push_back(1);
            sum++;
        }
        
        int t = 0, now = 0;
        vector<int> res(m+1);
        for(auto x: ans) {
            for(int i=1; i<=x; ++i) {
                res[++now] = t;
            }
            t ^= 1;
        }
        
        cout<<"YES\n";
        for(int i=1; i<=n; ++i) {
            for(int j=1; j<=m; ++j) {
                cout<<res[j]<<" \n"[j==m];
            }
        }
        return ;
    }
    cout<<"NO\n";
}

signed main(void) {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    for(i64 i=1; i<=1000000; ++i) {
        f[i] = i * (i-1)/2;
    }
    
    int t=1; cin>>t;
    while (t--) solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 10740kb

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)