結果

問題 No.1831 Parasol
ユーザー SSRSSSRS
提出日時 2022-02-04 21:56:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,134 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 205,560 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 04:49:14
合計ジャッジ時間 8,361 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  mt19937 mt(0);
  int N;
  cin >> N;
  while (true){
    vector<int> p(N * 2 - 1);
    for (int i = 0; i < N * 2 - 1; i++){
      p[i] = i + 1;
    }
    shuffle(p.begin(), p.end(), mt);
    int S = 0;
    vector<int> used(N * 2, false);
    used[0] = true;
    used[N * 2 - 1] = true;
    for (int i = 0; i < N * 2 - 1; i++){
      S += p[i];
      S %= N * 2 - 1;
      used[S] = true;
    }
    bool ok = true;
    for (int i = 0; i < N * 2 - 1; i++){
      if (!used[i] && !used[i + 1]){
        ok = false;
      }
    }
    if (ok){
      vector<vector<int>> ans(N * 2 - 1);
      S = 0;
      for (int i = 0; i < N * 2 - 1; i++){
        for (int j = 0; j < p[i]; j++){
          ans[S].push_back(p[i]);
          S++;
          if (S == N * 2 - 1){
            S = 0;
          }
        }
      }
      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;
      }
      break;
    }
  }
}
0