結果

問題 No.3649 Top View of Jenga
コンテスト
ユーザー ウソチー
提出日時 2026-08-28 22:55:29
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 414µs
コード長 6,688 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,036 ms
コンパイル使用メモリ 359,964 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-28 22:55:38
合計ジャッジ時間 6,525 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#include <iostream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

struct FastIO {
    FastIO() {
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
};
inline FastIO fast_io_init;

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v);

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    return is >> p.first >> p.second;
}

template <typename Tuple, std::size_t... I>
void read_tuple_impl(std::istream& is, Tuple& t, std::index_sequence<I...>) {
    (..., (is >> std::get<I>(t)));
}

template <typename... Args>
std::istream& operator>>(std::istream& is, std::tuple<Args...>& t) {
    read_tuple_impl(is, t, std::index_sequence_for<Args...>{});
    return is;
}

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

using default_type = long;

template <typename... Args>
void read(Args&... args) {
    (std::cin >> ... >> args);
}

template <typename T = default_type>
T read_val() {
    T val;
    std::cin >> val;
    return val;
}

template <typename T1 = default_type, typename T2 = default_type>
std::pair<T1, T2> read_pair() {
    std::pair<T1, T2> p;
    std::cin >> p;
    return p;
}

template <typename... Args>
std::tuple<Args...> read_tuple() {
    std::tuple<Args...> t;
    std::cin >> t;
    return t;
}

template <typename T = default_type>
std::vector<T> read_vec(int n) {
    std::vector<T> v(n);
    std::cin >> v;
    return v;
}

template <typename T = default_type>
std::vector<T> read_vec() {
    int n;
    std::cin >> n;
    return read_vec<T>(n);
}

template <typename T1 = default_type, typename T2 = default_type>
std::vector<std::pair<T1, T2>> read_vec_pair(int n) {
    std::vector<std::pair<T1, T2>> v(n);
    std::cin >> v;
    return v;
}

template <typename T1 = default_type, typename T2 = default_type>
std::vector<std::pair<T1, T2>> read_vec_pair() {
    int n;
    std::cin >> n;
    return read_vec_pair<T1, T2>(n);
}

template <typename... Args>
std::vector<std::tuple<Args...>> read_vec_tuple(int n) {
    std::vector<std::tuple<Args...>> v(n);
    std::cin >> v;
    return v;
}

template <typename... Args>
std::vector<std::tuple<Args...>> read_vec_tuple() {
    int n;
    std::cin >> n;
    return read_vec_tuple<Args...>(n);
}

template <typename T = default_type>
std::vector<std::vector<T>> read_vec_grid(int h, int w) {
    std::vector<std::vector<T>> grid(h, std::vector<T>(w));
    std::cin >> grid;
    return grid;
}

template <typename T = default_type>
std::vector<std::vector<T>> read_vec_grid() {
    int h, w;
    std::cin >> h >> w;
    return read_vec_grid<T>(h, w);
}

template <typename T = default_type>
std::vector<std::vector<T>> read_vec_var(int n) {
    std::vector<std::vector<T>> res(n);
    for (int i = 0; i < n; ++i) {
        int m;
        std::cin >> m;
        res[i] = read_vec<T>(m);
    }
    return res;
}

template <typename T = default_type>
std::vector<std::vector<T>> read_vec_var() {
    int n;
    std::cin >> n;
    return read_vec_var<T>(n);
}

template <typename T = default_type>
T read_zero_idx() {
    T val;
    std::cin >> val;
    return val - 1;
}

inline std::vector<std::vector<int>> read_graph(int n, int m, bool directed = false) {
    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u = read_zero_idx<int>();
        int v = read_zero_idx<int>();
        g[u].push_back(v);
        if (!directed) {
            g[v].push_back(u);
        }
    }
    return g;
}

inline std::vector<std::vector<int>> read_graph(bool directed = false) {
    int n, m;
    std::cin >> n >> m;
    return read_graph(n, m, directed);
}

#include <istream>
#include <numeric>
#include <print>
#include <vector>

#define ALL(a) (a).begin(), (a).end()
using i128 = __int128;

template <typename T, typename U>
inline bool chmin(T& a, const U& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T, typename U>
inline bool chmax(T& a, const U& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <std::integral T>
inline T div_ceil(T a, T b) {
    if (a > 0) return a / b + (a % b != 0);
    return a / b;
}

template <std::integral T>
inline T div_floor(T a, T b) {
    if (a < 0) return a / b - (a % b != 0);
    return a / b;
}

template <std::integral T>
inline T mod(T a, T m) {
    a %= m;
    if (a < 0) a += m;
    return a;
}

template <typename T>
inline constexpr T INF = std::numeric_limits<T>::max() / 2;

template <>
inline constexpr float INF<float> = std::numeric_limits<float>::infinity();

template <>
inline constexpr double INF<double> = std::numeric_limits<double>::infinity();

template <>
inline constexpr long double INF<long double> = std::numeric_limits<long double>::infinity();

template <typename T = int>
inline std::vector<T> iota_vec(int n, T start = 0) {
    std::vector<T> v(n);
    std::iota(v.begin(), v.end(), start);
    return v;
}

template <typename T>
inline std::vector<T> doubled_vec(const std::vector<T>& v) {
    std::vector<T> res;
    res.reserve(v.size() * 2);
    res.insert(res.end(), v.begin(), v.end());
    res.insert(res.end(), v.begin(), v.end());
    return res;
}

inline void Yes(bool b = true) {
    std::println("{}", (b ? "Yes" : "No"));
}

inline void No() {
    std::println("No");
}

#ifdef LOCAL
#include <utility/debug.hpp>
#else
#define debug(...)
#endif

long a[3][3];
void solve() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long N;
    read(N);
    long q = N / 6;
    long r = N % 6;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            a[i][j] = q * 2;
        }
    }
    for (int k = 0; k < r; k++) {
        if (k == 0) {
            for (int j = 0; j < 3; j++) {
                a[j][0]++;
            }
        }
        if (k == 1) {
            for (int j = 0; j < 3; j++) {
                a[j][1]++;
            }
        }
        if (k == 2) {
            for (int j = 0; j < 3; j++) {
                a[j][2]++;
            }
        }
        if (k == 3) {
            for (int j = 0; j < 3; j++) {
                a[0][j]++;
            }
        }
        if (k == 4) {
            for (int j = 0; j < 3; j++) {
                a[1][j]++;
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            print("{} ", a[i][j]);
        }
        println("{}", "");
    }
}

int main() {
    solve();
}
0