結果
問題 | No.1831 Parasol |
ユーザー |
![]() |
提出日時 | 2022-02-04 22:19:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 77,976 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 12:01:47 |
合計ジャッジ時間 | 2,181 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
#include <iostream>#include <queue>using namespace std;typedef pair<int, int> P;int main(){int n;cin >> n;cout << n * 2 - 1 << endl;int r = n;for(int i = 0; i < n; i++){for(int j = 0; j < n; j++){cout << r + n - 1 << " ";r = (r + 1) % (n + 1);}cout << endl;}priority_queue<P> que;for(int i = 1; i < n - 1; i++) que.push(P(i, i));for(int i = n - 1; i < n * 2 - 1; i++) que.push(P(i - (n - 1), i));que.push(P(n - 1, n * 2 - 1));for(int i = 0; i < n - 1; i++){vector<P> v;for(int j = 0; j < n; j++){v.push_back(que.top());que.pop();v.back().first--;}for(P p : v){cout << p.second << " ";que.push(p);}cout << endl;}}