結果

問題 No.1384 Bishop and Rook
ユーザー SSRSSSRS
提出日時 2021-02-07 21:28:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,361 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 167,744 KB
実行使用メモリ 12,028 KB
最終ジャッジ日時 2023-09-17 20:37:10
合計ジャッジ時間 19,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 769 ms
10,284 KB
testcase_02 AC 360 ms
5,212 KB
testcase_03 AC 143 ms
4,376 KB
testcase_04 AC 202 ms
4,380 KB
testcase_05 AC 544 ms
5,584 KB
testcase_06 AC 714 ms
7,100 KB
testcase_07 AC 833 ms
9,588 KB
testcase_08 AC 634 ms
6,312 KB
testcase_09 AC 15 ms
4,376 KB
testcase_10 AC 445 ms
6,092 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 20 ms
4,376 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 1,123 ms
9,772 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 1,343 ms
10,788 KB
testcase_17 AC 11 ms
4,376 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 1,037 ms
12,028 KB
testcase_20 AC 12 ms
4,380 KB
testcase_21 AC 36 ms
4,380 KB
testcase_22 AC 35 ms
4,376 KB
testcase_23 AC 29 ms
4,376 KB
testcase_24 AC 36 ms
4,384 KB
testcase_25 AC 35 ms
4,376 KB
testcase_26 AC 32 ms
4,376 KB
testcase_27 AC 32 ms
4,380 KB
testcase_28 AC 31 ms
4,376 KB
testcase_29 AC 34 ms
4,376 KB
testcase_30 AC 29 ms
4,376 KB
testcase_31 AC 22 ms
4,376 KB
testcase_32 AC 29 ms
4,376 KB
testcase_33 AC 27 ms
4,380 KB
testcase_34 AC 26 ms
4,376 KB
testcase_35 AC 26 ms
4,380 KB
testcase_36 AC 19 ms
4,380 KB
testcase_37 AC 18 ms
4,380 KB
testcase_38 AC 17 ms
4,380 KB
testcase_39 AC 17 ms
4,380 KB
testcase_40 AC 20 ms
4,380 KB
testcase_41 AC 130 ms
4,376 KB
testcase_42 AC 127 ms
4,376 KB
testcase_43 AC 154 ms
4,380 KB
testcase_44 AC 176 ms
4,380 KB
testcase_45 AC 171 ms
4,380 KB
testcase_46 AC 141 ms
4,380 KB
testcase_47 AC 155 ms
4,376 KB
testcase_48 AC 147 ms
4,380 KB
testcase_49 AC 88 ms
4,380 KB
testcase_50 AC 84 ms
4,376 KB
testcase_51 AC 4 ms
4,376 KB
testcase_52 AC 1,361 ms
11,100 KB
testcase_53 AC 553 ms
5,408 KB
testcase_54 AC 5 ms
4,380 KB
testcase_55 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    int N, M;
    cin >> N >> M;
    if (N == 1 && M == 1){
      cout << 0 << endl;
      cout << 1 << ' ' << 1 << endl;
    } else if (N % 2 == 0 && M % 2 == 0){
      cout << N * M - 1 << endl;
      vector<int> x, y;
      for (int j = 0; j < N; j += 2){
        for (int k = 0; k < M; k++){
          if (k % 4 == 0 || k % 4 == 3){
            x.push_back(j);
          } else {
            x.push_back(j + 1);
          }
          y.push_back(k);
        }
        for (int k = M - 1; k >= 0; k--){
          if (k % 4 == 1 || k % 4 == 2){
            x.push_back(j);
          } else {
            x.push_back(j + 1);
          }
          y.push_back(k);
        }
      }
      for (int j = 0; j < N * M; j++){
        cout << x[j] + 1 << ' ' << y[j] + 1 << endl;
      }
    } else {
      cout << -1 << endl;
    }
  }
}
0