結果

問題 No.1619 Coccinellidae
ユーザー sten_sansten_san
提出日時 2021-07-22 22:29:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,528 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 203,048 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-09-24 17:44:15
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 100 ms
4,420 KB
testcase_02 AC 130 ms
4,736 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 131 ms
4,572 KB
testcase_05 AC 77 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 79 ms
4,376 KB
testcase_08 AC 74 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 66 ms
4,376 KB
testcase_11 AC 92 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 125 ms
4,604 KB
testcase_14 AC 129 ms
4,876 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

int main() {
    int64_t n, m, k; cin >> n >> m >> k;

    auto a = [&] {
        auto a = vec<int64_t>(uns, n);

        auto r = m;
        for (int i = 0; i < n - 1; ++i) {
            a[i] = i;
            r -= i;
        }
        a[n - 1] = r;

        return a;
    }();

    int shift = 0;

    int64_t r = k;
    for (int i = 0; i < n && n - i - 1 <= r; ++i) {
        r -= n - i - 1;
        ++shift;
    }

    auto b = vec<int64_t>(uns, n);

    for (int i = 0; i < shift; ++i) {
        b[i] = a[n - i - 1];
    }

    for (int i = shift; i < n; ++i) {
        b[i] = a[i - shift];
    }

    rotate(end(b) - (r + 1), end(b) - 1, end(b));

    for (auto v : b) {
        cout << v << endl;
    }
}

0