結果
問題 | No.883 ぬりえ |
ユーザー | pekempey |
提出日時 | 2019-09-13 22:14:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 982 bytes |
コンパイル時間 | 1,699 ms |
コンパイル使用メモリ | 179,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 10:34:22 |
合計ジャッジ時間 | 2,708 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define range(a) a.begin(), a.end() using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, K; cin >> N >> K; for (int k = 1;; k++) { priority_queue<pair<int, int>> q; rep(i, k) { q.emplace(K, i); } vector<vector<int>> ans(k); int y = N; rep(i, k) { vector<pair<int, int>> tmp; rep(j, K) if (y > 0 && !q.empty()) { tmp.push_back(q.top()); q.pop(); y--; } for (auto p : tmp) { ans[i].push_back(p.second); if (p.first > 1) { q.emplace(p.first - 1, p.second); } } } if (y == 0) { vector<string> grid(k, string(k, '.')); rep(i, k) for (int j : ans[i]) grid[i][j] = '#'; cout << k << endl; rep(i, k) cout << grid[i] << '\n'; return 0; } } }