QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296946#6309. AqrewsyearWA 2ms3616kbC++142.0kb2024-01-03 20:09:512024-01-03 20:09:52

Judging History

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

  • [2024-01-03 20:09:52]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3616kb
  • [2024-01-03 20:09:51]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D("[Debug] "#__VA_ARGS__ " = "), \
              debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 1010;

int n, m, flag, a[maxn][maxn], b[maxn][maxn];

void work() {
  cin >> n >> m, flag = (n > m);
  if (n <= 3 && m <= 3) {
    cout << n * m << '\n';
    rep (i, 1, n) {
      rep (j, 1, m) cout << 1;
      cout << "\n";
    }
    return;
  }
  if (n > m) swap(n, m);
  rep (i, 1, n) rep (j, 1, m) a[i][j] = 1;
  if (n == 2) {
    for (int j = 2; j <= m; j += 4) a[1][j] = 0;
    for (int j = 4; j <= m; j += 4) a[2][j] = 0;
  } else if (n == 3) {
    for (int j = 2; j <= m; j += 4) a[1][j] = 0;
    for (int j = 2; j <= m; j += 4) a[2][j] = 0;
    for (int j = 4; j <= m; j += 4) a[3][j] = 0;
  } else {
    rep (i, 1, n) {
      int beg = 0;
      if (i % 4 == 1) beg = 4;
      if (i % 4 == 2) beg = 2;
      if (i % 4 == 3) beg = 3;
      if (i % 4 == 0) beg = 1;
      for (int j = beg; j <= m; j += 4) a[i][j] = 0;
    }
  }
  if (flag) {
    rep (i, 1, n) rep (j, 1, m) b[j][i] = a[i][j];
    swap(n, m);
  } else {
    rep (i, 1, n) rep (j, 1, m) b[i][j] = a[i][j];
  }
  int cnt = 0;
  rep (i, 1, n) rep (j, 1, m) cnt += b[i][j];
  cout << cnt << '\n';
  rep (i, 1, n) {
    rep (j, 1, m) cout << b[i][j];
    cout << '\n';
  }
}

int main() {
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  int t; cin >> t;
  while (t--) work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3476kb

input:

3
2 2
3 4
3 8

output:

4
11
11
9
1011
1011
1110
18
10111011
10111011
11101110

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3616kb

input:

361
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
3 16
3 17
3 18
3 19
3 20
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 12
4 13
4 14
4 15
4 16
4 17
4 18
4 19
4 20
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 1...

output:

4
11
11
6
111
111
6
1011
1110
8
10111
11101
9
101110
111011
11
1011101
1110111
12
10111011
11101110
14
101110111
111011101
15
1011101110
1110111011
17
10111011101
11101110111
18
101110111011
111011101110
20
1011101110111
1110111011101
21
10111011101110
11101110111011
23
101110111011101
1110111011101...

result:

wrong answer ans finds a larger answer (test case 24)