結果

問題 No.2233 Average
ユーザー ruthenruthen
提出日時 2023-03-03 21:50:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 634 ms / 2,000 ms
コード長 1,232 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 216,332 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 01:48:23
合計ジャッジ時間 6,497 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 183 ms
4,348 KB
testcase_09 AC 277 ms
4,348 KB
testcase_10 AC 302 ms
4,348 KB
testcase_11 AC 294 ms
4,348 KB
testcase_12 AC 256 ms
4,348 KB
testcase_13 AC 59 ms
4,348 KB
testcase_14 AC 154 ms
4,348 KB
testcase_15 AC 213 ms
4,348 KB
testcase_16 AC 60 ms
4,348 KB
testcase_17 AC 85 ms
4,348 KB
testcase_18 AC 634 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        long long a, b, c, K;
        cin >> a >> b >> c >> K;
        map<tuple<long long, long long, long long>, int> mp;
        V<tuple<long long, long long, long long>> his;
        his.push_back({a, b, c});
        mp[{a, b, c}] = 0;
        for (int t = 1; t <= K; t++) {
            long long na = (b + c) / 2, nb = (c + a) / 2, nc = (a + b) / 2;
            show(na, nb, nc);
            if (mp.count({na, nb, nc})) {
                int cy = t - mp[{na, nb, nc}];
                int rem = (K - t) % cy;
                auto [ma, mb, mc] = his[mp[{na, nb, nc}] + rem];
                a = ma, b = mb, c - mc;
                break;
            } else {
                mp[{na, nb, nc}] = t;
                his.push_back({na, nb, nc});
                a = na, b = nb, c = nc;
            }
            show(mp, his);
        }
        cout << a + b + c << '\n';
    }
    return 0;
}
0