QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132643#6743. water235bucketpotato#WA 1ms3488kbC++20829b2023-07-30 22:36:382023-07-30 22:36:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-30 22:36:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3488kb
  • [2023-07-30 22:36:38]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

int main() {

  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, m; cin >> n >> m;

  cout << max(n, m) << "\n";

  vector<vector<int>> ans(n, vector<int>(m));

  if (n >= m) {
    int ci = 0;
    int chg = 1;
    for (int i = 0; i < n; i++) {
      ans[i][ci] = 1;
      ci += chg;

      if (ci == m || ci == -1) {
        chg *= -1;
        ci += chg;
      }
      
    }
  }
  else {
    int ci = 0;
    int chg = 1;
    for (int i = 0; i < m; i++) {
      ans[ci][i] = 1;
      ci += chg;
      if (ci == n || ci == -1) {
        chg *= -1;
        ci += chg;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << ans[i][j] << " \n"[j == m - 1];
    }
  }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1

output:

2
1
1

result:

ok The answer is correct.

Test #2:

score: 0
Accepted
time: 1ms
memory: 3488kb

input:

3 3

output:

3
1 0 0
0 1 0
0 0 1

result:

ok The answer is correct.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3456kb

input:

1 4

output:

4
1 1 1 1

result:

wrong answer The answer is wrong: expected = 3, found = 4