結果

問題 No.2339 Factorial Paths
ユーザー kotatsugamekotatsugame
提出日時 2023-06-02 22:41:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 81,944 KB
実行使用メモリ 6,416 KB
最終ジャッジ日時 2023-08-28 04:54:31
合計ジャッジ時間 7,466 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 6 ms
5,164 KB
testcase_17 AC 7 ms
6,060 KB
testcase_18 AC 8 ms
5,968 KB
testcase_19 AC 8 ms
5,964 KB
testcase_20 AC 8 ms
5,952 KB
testcase_21 AC 8 ms
6,416 KB
testcase_22 AC 8 ms
6,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<deque>
#include<cassert>
using namespace std;
vector<pair<int,int> >V;
int H,W;
void f(int N)
{
	if(N==1)return;
	if(N%2==0)
	{
		H+=N/2;
		W+=N/2;
		V.push_back(make_pair(N/2,N/2));
		f(N/2);
		f(N/2);
	}
	else
	{
		H+=(N+1)/2;
		W+=(N-1)/2;
		V.push_back(make_pair((N+1)/2,(N-1)/2));
		f((N+1)/2);
		f((N-1)/2);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	f(N);
	cout<<H+1<<" "<<W+1<<"\n";
	vector<string>S(H+1,string(W+1,'#'));
	int x=0,y=0;
	V.push_back(make_pair(0,0));
	for(pair<int,int>hw:V)
	{
		for(int i=0;i<=hw.first;i++)for(int j=0;j<=hw.second;j++)
		{
			S[x+i][y+j]='.';
		}
		x+=hw.first;
		y+=hw.second;
	}
	for(int i=0;i<=H;i++)cout<<S[i]<<"\n";
}
0