QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#766488 | #5438. Half Mixed | Yue_chen | WA | 3ms | 10740kb | C++17 | 2.0kb | 2024-11-20 17:29:56 | 2024-11-20 17:30:02 |
Judging History
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)