結果
問題 | No.883 ぬりえ |
ユーザー |
![]() |
提出日時 | 2019-09-13 22:14:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,886 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 86,360 KB |
実行使用メモリ | 35,712 KB |
最終ジャッジ日時 | 2024-07-04 09:51:35 |
合計ジャッジ時間 | 3,285 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 WA * 9 |
ソースコード
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <queue> #include <set> #include <map> #include <functional> #include <cmath> #include <cassert> #include <string> #include <iostream> using namespace std; typedef long long ll; ll MOD = 1000000007; typedef pair<int, int> P; string grid[1010][1010]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; if (n <= k * k) { cout << ceil((double)n / (double)k) << endl; ll cnt = 0; for (int i = 0; i < k; i++) { for (int j = 0; j < k; j++) { if (cnt < n) { cout << "#"; } else { cout << "."; } cnt++; } cout << endl; } } else { int t = k * k, ans = k; while (true) { if (n - t < k) { break; } t += k; ans++; } if (n - t == 1) { ans += 1; } else if (n - t == 2) { ans += 2; } else if (n - t >= 3) { ans += 3; } cout << ans << endl; ll cnt = 0; for (int i = 0; i < ans; i++) { for (int j = 0; j < ans; j++) { grid[i][j] = "."; } } for (int i = 0; i < ans; i = i + k) { for (int a = i; a < k + i; a++) { for (int b = i; b < k + i; b++) { if (cnt < n) { grid[a][b] = "#"; } cnt++; } } } for (int i = 0; i < ans; i++) { for (int j = 0; j < ans; j++) { cout << grid[i][j]; } cout << endl; } } }