結果
| 問題 | No.883 ぬりえ |
| コンテスト | |
| ユーザー |
noisy_noimin
|
| 提出日時 | 2019-09-13 21:59:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,891 bytes |
| 記録 | |
| コンパイル時間 | 1,086 ms |
| コンパイル使用メモリ | 108,636 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-04 04:14:36 |
| 合計ジャッジ時間 | 2,812 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 8 |
ソースコード
#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;
}
}
noisy_noimin