結果

問題 No.1831 Parasol
ユーザー simansiman
提出日時 2022-02-06 11:50:49
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 5,416 ms
コンパイル使用メモリ 104,536 KB
実行使用メモリ 5,500 KB
最終ジャッジ日時 2023-09-02 06:58:13
合計ジャッジ時間 7,235 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 21 ms
5,420 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 22 ms
5,500 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 20 ms
5,388 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 15 ms
4,768 KB
testcase_11 AC 21 ms
5,496 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 20 ms
5,416 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int mapping[2 * N][2 * N];
  memset(mapping, -1, sizeof(mapping));

  for (int x = 2 * N - 1; x >= 1; --x) {
    if (x % 2 == 0) {
      for (int y = 1; y <= x; ++y) {
        mapping[y][x] = 2 * N - y;
      }
    } else {
      for (int y = x; y >= 1; --y) {
        mapping[y][x] = x - y + 1;
      }
    }
  }

  vector<int> counter(2 * N, 0);
  int ans[2 * N][N];
  for (int y = 1; y <= 2 * N - 1; ++y) {
    for (int x = 1; x <= 2 * N - 1; ++x) {
      int id = mapping[y][x];
      if (id == -1) continue;

      int idx = counter[id];
      ans[id][idx] = x;
      counter[id]++;
    }
  }

  cout << 2 * N - 1 << endl;
  for (int id = 1; id <= 2 * N - 1; ++id) {
    for (int i = 0; i < N; ++i) {
      cout << ans[id][i];
      if (i != N - 1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}
0