結果

問題 No.2339 Factorial Paths
ユーザー shobonvipshobonvip
提出日時 2023-06-03 02:25:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,182 bytes
コンパイル時間 4,657 ms
コンパイル使用メモリ 265,828 KB
実行使用メモリ 6,728 KB
最終ジャッジ日時 2023-08-28 07:32:02
合計ジャッジ時間 11,481 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 21 ms
4,832 KB
testcase_16 AC 32 ms
5,752 KB
testcase_17 AC 40 ms
6,488 KB
testcase_18 AC 44 ms
6,652 KB
testcase_19 AC 45 ms
6,664 KB
testcase_20 AC 45 ms
6,680 KB
testcase_21 AC 45 ms
6,688 KB
testcase_22 AC 45 ms
6,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef modint998244353 mint;
typedef long long ll;

void divide(int n, vector<pair<int,int>> &g){
	if (n == 1) return;
	if (n == 3){
		g.push_back(pair(3, 3));
		return;
	}
	int t = n / 2;
	int s = n - t;
	g.push_back(pair(t+1, s+1));
	divide(t, g);
	divide(s, g);
}

int main(){
	int n; cin >> n;
	if (n == 1){
		cout << 1 << " " << 1 << endl;
		cout << "." << endl;
		return 0;
	}
	vector<pair<int,int>> g;
	int h = 0, w = 0;
	divide(n, g);
	for (int i=0; i<(int)g.size(); i++){
		if (g[i].first < g[i].second){
			swap(g[i].first, g[i].second);
		}
		h += g[i].first;
		w += g[i].second;
		//cout << g[i].first << " " << g[i].second << endl;
	}
	h -= (int)g.size() - 1;
	vector<vector<char>> s(h, vector<char>(w, '#'));
	int ph = 0;
	int pw = 0;
	for (int i=0; i<(int)g.size(); i++){
		for (int x=ph; x<ph+g[i].first; x++){
			for (int y=pw; y<pw+g[i].second; y++){
				s[x][y] = '.';
			}
		}
		ph += g[i].first - 1;
		pw += g[i].second;
	}
	cout << h << " " << w << endl;
	//return 0;
	for (int i=0; i<h; i++){
		for (int j=0; j<w; j++){
			cout << s[i][j];
		}
		cout << endl;
	}
}
0