結果

問題 No.1831 Parasol
ユーザー SSRSSSRS
提出日時 2022-02-04 22:08:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 895 bytes
コンパイル時間 3,161 ms
コンパイル使用メモリ 207,780 KB
実行使用メモリ 4,848 KB
最終ジャッジ日時 2023-09-02 04:56:42
合計ジャッジ時間 5,557 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> ans(N * 2 - 1);
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
  for (int i = 1; i <= N * 2 - 1; i++){
    int R = i;
    if (i % 2 == 1){
      ans[N * 2 - 2].push_back(i);
      R--;
    }
    if (i >= 2 && i <= N){
      ans[i * 2 - 4].push_back(i);
      ans[i * 2 - 3].push_back(i);
      R -= 2;
      pq.push(make_pair(1, i * 2 - 4));
      pq.push(make_pair(1, i * 2 - 3));
    }
    for (int j = 0; j < R; j++){
      int p = pq.top().second;
      pq.pop();
      ans[p].push_back(i);
      pq.push(make_pair(ans[p].size(), p));
    }
  }
  cout << N * 2 - 1 << endl;
  for (int i = 0; i < N * 2 - 1; i++){
    for (int j = 0; j < N; j++){
      cout << ans[i][j];
      if (j < N - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}
0