結果

問題 No.883 ぬりえ
ユーザー 夜
提出日時 2020-12-08 18:36:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 95,236 KB
実行使用メモリ 5,588 KB
最終ジャッジ日時 2023-10-17 18:54:15
合計ジャッジ時間 3,135 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
string s[1010];
int main() {
	int n, k;
	cin >> n >> k;
	int ans = (n + k * k - 1) / (k * k);
	ans *= k;
	for (int i = 0; i < ans; i++) {
		s[i] = "";
		for (int j = 0; j < ans; j++) {
			s[i] += '.';
		}
	}
	for (int i = 0; i < ans; i++) {
		s[i][i / k * k] = '#';
		s[i / k * k][i] = '#';
	}
	for (int i = 1; i < ans; i++) {
		for (int j = 1; j < ans; j++) {
			if (s[i - 1][j] == '#' && s[i][j - 1] == '#') {
				s[i][j] = '#';
			}
		}
	}
	int co = 0;
	for (int i = 0; i < ans; i++) {
		for (int j = 0; j < ans; j++) {
			if (s[i][j] == '#') {
				co++;
			}
		}
	}
	for (int i = ans - 1; i >= 0; i--) {
		for (int j = ans - 1; j >= 0; j--) {
			if (s[i][j] == '#') {
				if (co > n) {
					s[i][j] = '.';
					co--;
				}
			}
		}
	}
	int m = -1;
	for (int i = 0; i < ans; i++) {
		for (int j = 0; j < ans; j++) {
			if (s[i][j] == '#') {
				if (m < i) {
					m = i;
				}
				if (m < j) {
					m = j;
				}
			}
		}
	}
	cout << m + 1 << endl;
	for (int i = 0; i <= m; i++) {
		cout << s[i].substr(0, m + 1) << endl;
	}
}
0