結果

問題 No.883 ぬりえ
ユーザー suika_psuika_p
提出日時 2019-09-13 22:26:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,507 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 168,024 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-09-17 15:30:20
合計ジャッジ時間 2,831 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K; cin >> N >> K;
    int g = (N + (K - 1)) / K;
    if (g < K) {
        int num = 0;
        REP(i, 1, N+1) {
            if (i * i >= N) {
                num = i;
                break;
            }
        }
        vector<string> maze(num);
        int cnt = 0;
        rep(i, num) rep(j, num) {
            if (cnt >= N) maze[i].pb('.');
            else maze[i].pb('#');
            cnt++;
        }
        cout << num << endl;
        rep(i, num) cout << maze[i] << endl;
        return 0;
    }
    vector<string> maze(g);
    rep(i, g) rep(j, g) maze[i].pb('.');
    int cnt = 0;
    bool f = true;
    rep(i, g) {
        REP(j, i, K+i) {
            if (j >= g) maze[i][j-g] = '#';
            else maze[i][j] = '#';
            cnt++;
            if (cnt >= N) {
                f = false;
                break;
            }
        }
        if (!f) break;
    }
    cout << g << endl;
    rep(i, g) cout << maze[i] << endl;
    return 0;
}
0