結果

問題 No.883 ぬりえ
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-09-13 21:59:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,891 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 106,556 KB
実行使用メモリ 6,020 KB
最終ジャッジ日時 2023-09-17 07:15:10
合計ジャッジ時間 3,244 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 3 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 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}
};

map<Pll, ll> memo;

ll comb(ll n, ll r){
    if(n < r) return 0;
    if(n == r || r == 0){
        return 1;
    }else if(r == 1){
        return n;
    }else if(memo[Pll(n, r)] != 0){
        return memo[Pll(n, r)];
    }else{
        ll tmp = comb(n-1, r-1) + comb(n-1, r);
        return memo[Pll(n, r)] = min(2000LL, tmp);
    }
}

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;
        // cerr << mid << ": " << comb(mid, k) * k << " " << n << endl;
        if(comb(mid, k) * k >= n) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok = max(ok, n/k);
    cout << ok << endl;

    vector<vector<char>> a(ok, vector<char>(ok, '.'));
    vector<ll> line_count(ok), row_count(ok);
    int j = 0, cnt = 0;
    for(int i=0;i<ok && 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 == ok) j = 0;
        }
    }

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

}
0