結果

問題 No.3729 I Hate Hexagonal Tiling
コンテスト
ユーザー DB0917
提出日時 2026-09-19 16:24:11
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
+ 368µs
コード長 1,830 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,922 ms
コンパイル使用メモリ 355,688 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-09-19 16:24:17
合計ジャッジ時間 6,307 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using i128 = __int128;
using db = double;
using ld = long double;
#define int ll
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

const int INF=LLONG_MAX/4;
const int MOD=998244353;

random_device rd;
mt19937_64 gen(rd());

void pre_do(){

}

void solve(){	

	int n; cin >> n;
	vector<vector<int>> a1(n), a2(n), a3(n);
	int s1, s2, s3;
	s1 = s2 = s3 = 4;
	a1[0] = {1};
	a1[1] = {2, 1};
	a2[0] = {1};
	a2[1] = {1, 2};
	a3[0] = {2};
	a3[1] = {1, 1};

	for(int i=2;i<n;i++){
		a1[i].resize(i+1);
		a2[i].resize(i+1);
		a3[i].resize(i+1);
		for(int j=1;j<i;j++){
			a1[i][j] = 4- a1[i-1][j-1] - a1[i-1][j];
			s1 += a1[i][j];
			a2[i][j] = 4 - a2[i-1][j-1] - a2[i-1][j];
			s2 += a2[i][j];
			a3[i][j] = 4 - a3[i-1][j-1] - a3[i-1][j];
			s3 += a3[i][j];
		}
		a1[i][0] = 4 - a1[i-1][0] - a1[i][1];
		s1 += a1[i][0];
		a2[i][0] = 4 - a2[i-1][0] - a2[i][1];
		s2 += a2[i][0];
		a3[i][0] = 4 - a3[i-1][0] - a3[i][1];
		s3 += a3[i][0];

		a1[i][i] = 4 - a1[i-1][i-1] - a1[i][i-1];
		s1 += a1[i][i];
		a2[i][i] = 4 - a2[i-1][i-1] - a2[i][i-1];
		s2 += a2[i][i];
		a3[i][i] = 4 - a3[i-1][i-1] - a3[i][i-1];
		s3 += a3[i][i];
	}
	if(min({s1, s2, s3})==s1){
		for(int i=0;i<n;i++){
			for(auto& e : a1[i]){
				cout << e << ' ';
			}
			cout << '\n';
		}
	}
	else if(min({s1, s2, s3})==s2){
		for(int i=0;i<n;i++){
			for(auto& e : a2[i]){
				cout << e << ' ';
			}
			cout << '\n';
		}
	}
	else{
		for(int i=0;i<n;i++){
			for(auto& e : a3[i]){
				cout << e << ' ';
			}
			cout << '\n';
		}
	}

}
 	
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	pre_do();

	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
	//cout << "FINISH\n";
}
0