QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#131519#6743. water235ClHg2WA 1ms3636kbC++141.8kb2023-07-27 13:12:002023-07-27 13:12:01

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-27 13:12:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3636kb
  • [2023-07-27 13:12:00]
  • 提交

answer

#include <array>
#include <cstddef>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <string>

namespace {
using std::cin;
using std::cout;
using std::int64_t;
using std::size_t;

namespace base {
template <typename T, size_t... sizes>
struct NestedArray {};

template <typename T, size_t size, size_t... sizes>
struct NestedArray<T, size, sizes...> {
  using Type = std::array<typename NestedArray<T, sizes...>::Type, size>;
};

template <typename T>
struct NestedArray<T> {
  using Type = T;
};

template <typename T, size_t... sizes>
using Array = typename NestedArray<T, sizes...>::Type;

void OptimizeIO() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
}

void OptimizeIO(const std::string &input_file, const std::string &output_file) {
  static std::ifstream input_stream(input_file);
  static std::ofstream output_stream(output_file);
  cin.rdbuf(input_stream.rdbuf()), cout.rdbuf(output_stream.rdbuf());
  cin.tie(nullptr), cout.tie(nullptr);
}
}  // namespace base

using base::Array;

int Main() {
  base::OptimizeIO();
  int n, m;
  cin >> n >> m;
  int x = 1 + (n >> 1) + (m >> 1), y = ((n + 1) >> 1) + ((m + 1) >> 1);

  if (x <= y) {
    cout << x << "\n";
    for (int i = 1; i <= m >> 1; ++i) cout << "1 0 ";
    if (m & 1) cout << "1 ";
    cout << "\n";

    for (int i = 2; i <= n; ++i) {
      cout << (i & 1 || i == n) << " ";
      for (int j = 2; j <= m; ++j) cout << "0 ";
      cout << "\n";
    }
  } else {
    cout << y << "\n";
    for (int i = 1; i <= m; ++i) cout << (!(i & 1) || (i == m)) << " ";

    for (int i = 2; i <= n; ++i) {
      cout << (!(i & 1) || (i == n)) << " ";
      for (int j = 2; j <= m; ++j) cout << "0 ";
      cout << "\n";
    }
  }

  return 0;
}
}  // namespace

int main() { return Main(); }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1

output:

2
1 
1 

result:

ok The answer is correct.

Test #2:

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

input:

3 3

output:

3
1 0 1 
0 0 0 
1 0 0 

result:

ok The answer is correct.

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3636kb

input:

1 4

output:

3
1 0 1 0 

result:

wrong answer Invalid output