結果
問題 | No.1831 Parasol |
ユーザー |
|
提出日時 | 2022-02-04 23:45:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,103 bytes |
コンパイル時間 | 806 ms |
コンパイル使用メモリ | 75,624 KB |
最終ジャッジ日時 | 2025-01-27 20:09:20 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 12 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> ans; int M = 2 * N - 1; for (int i = 0; i < M; i++) { ans.push_back(M); } int now = 0; vector<bool> did(2 * N - 1, false), usd(2 * N, false); did[0] = true; usd[M] = true; int cnt = 0; for (int i = 1; i < M; i++) { int fl = 1; while (fl < M && (did[(now + fl) % M] || usd[fl])) fl++; if (fl == M) { /*if (cnt) { return 0; }*/ fl = 1; while (usd[fl]) { fl++; } cnt++; } //cout << fl << endl; for (int j = 0; j < fl; j++) { ans.push_back(fl); } did[(now + fl) % M] = true; usd[fl] = true; now = (now + fl) % M; } cout << 2 * N - 1 << endl; for (int i = 0; i < 2 * N - 1; i++) { for (int j = 0; j < N; j++) { cout << ans[i + j * (2 * N - 1)] << (j < N - 1 ? " " : ""); } cout << endl; } }