結果

問題 No.883 ぬりえ
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-09-13 22:12:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,619 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 99,964 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-09-17 15:29:49
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,412 KB
testcase_04 AC 3 ms
4,412 KB
testcase_05 AC 2 ms
4,512 KB
testcase_06 AC 3 ms
4,400 KB
testcase_07 AC 2 ms
4,464 KB
testcase_08 AC 3 ms
4,572 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,528 KB
testcase_11 AC 3 ms
4,564 KB
testcase_12 AC 2 ms
4,452 KB
testcase_13 AC 2 ms
4,392 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 14 ms
4,428 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 3 ms
4,424 KB
testcase_20 AC 2 ms
4,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

vector<vector<char>> a(1000, vector<char>(1000, '.'));

bool is_ok(int n_lines, ll n, ll k) {
    k = min(int(k), n_lines);
    a.assign(n_lines, vector<char>(1000, '.'));
    vector<ll> line_count(n_lines, 0), row_count(n_lines, 0);
    int j = 0, cnt = 0;
    for(int i=0;i<n_lines && cnt<n;++i) {
        while(cnt < n && line_count[i] < k) {
            if(row_count[j] < k) {
                a[i][j] = '#';
                ++line_count[i];
                ++row_count[j];
                ++cnt;
            }
            ++j;
            if(j == n_lines) j = 0;
        }
    }
    return (cnt == n);
}


int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;

    ll ng = 0, ok = 1000;
    while(ok-ng > 1) {
        ll mid = (ng+ok) / 2;
        if(is_ok(mid, n, k)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    is_ok(ok, n, k);
    for(int i=0;i<ok;++i) {
        for(int j=0;j<ok;++j) {
            cout << a[i][j];
        }
        cout << endl;
    }

}
0