QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397846#5438. Half MixedcaijianhongWA 0ms3628kbC++141.3kb2024-04-24 17:38:312024-04-24 17:38:31

Judging History

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

  • [2024-04-24 17:38:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-04-24 17:38:31]
  • 提交

answer

// 

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define debug(...) fprintf(stderr, ##__VA_ARGS__)
#else
#define endl "\n"
#define debug(...) void(0)
#endif
typedef long long LL;
vector<int> knapsack(int n, LL m) {
  // (n, m)
  // (x, (x - 1) * x / 2)
  vector<int> ret;
  while (m) {
    LL x = sqrt(x);
    while (x * (x + 1) / 2 <= m) x += 1;
    while (x * (x - 1) / 2 > m) x -= 1;
    ret.push_back(x);
    n -= x;
    m -= x * (x - 1) / 2;
  }
  assert(n >= 0);
  ret.insert(ret.end(), n, 1);
  return ret;
}
auto solve(int n) { return knapsack(n, 1ll * n * (n + 1) / 4 - n); }
int main() {
#ifndef LOCAL
  cin.tie(nullptr)->sync_with_stdio(false);  
#endif
  int t;
  cin >> t;
  while(t--) {
  int n, m;
  cin >> n >> m;
  if (1ll * m * (m + 1) % 4 == 0) {
    string s;
    auto ret = solve(m);
    int c = 0;
    for (int len : ret) s.append(len, c + '0'), c ^= 1;
    cout << "Yes" << endl;
    for (int i = 1; i <= n; i++) cout << s << endl;
  } else if (1ll * n * (n + 1) % 4 == 0) {
    string s;
    auto ret = solve(n);
    int c = 0;
    for (int len : ret) s.append(len, c + '0'), c ^= 1;
    cout << "Yes" << endl;
    for (auto ch : s) cout << string(m, ch) << endl;
  } else {
    cout << "No" << endl;
  }
  }
  return 0;
}

詳細信息

Test #1:

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

input:

2
2 3
1 1

output:

Yes
010
010
No

result:

wrong output format Expected integer, but "010" found (test case 1)