結果

問題 No.3729 I Hate Hexagonal Tiling
コンテスト
ユーザー downer
提出日時 2026-09-19 15:10:27
言語 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
+ 205µs
コード長 759 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,863 ms
コンパイル使用メモリ 354,564 KB
実行使用メモリ 9,996 KB
最終ジャッジ日時 2026-09-19 15:10:34
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int pat[3][3] = {
    {2, 1, 1},
    {1, 1, 2},
    {1, 2, 1}
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> cur = {2};

    int mn = 1e9;
    int mn_ofs = 0;
    for(int ofs : {0, 1, 2}) {
        int sm = 0;
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < i + 1; j++) {
                sm += pat[(i + ofs) % 3][j % 3];
            }
        }

        if(mn > sm) {
            mn = sm;
            mn_ofs = ofs;
        }
    }
    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < i + 1; j++) {
            cout << pat[(i + mn_ofs) % 3][j % 3] << " ";
        }
        cout << "\n";
    }

    return 0;
}
0