結果

問題 No.1257 変わった平均値
ユーザー YamaKasaYamaKasa
提出日時 2020-10-17 03:08:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,599 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-28 07:17:37
合計ジャッジ時間 3,587 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int D, E, F;

bool flag = false;
string sovle(int a, int b, int c) {
    string t = "";
    flag = false;
    while (true) {
        if (2 * a <= D && 2 * b <= E) {
            a *= 2;
            b *= 2;
            if (t.length() == 0) {
                t = "2 F 2 F";
            } else {
                t += " 2 F 2 F";
            }
        } else {
            break;
        }
    }
    while (true) {
        if (2 * a <= D && 2 * c <= F) {
            a *= 2;
            c *= 2;
            if (t.length() == 0) {
                t = "2 E 2 E";
            } else {
                t += " 2 E 2 E";
            }
        } else {
            break;
        }
    }
    while (true) {
        if (2 * b <= E && 2 * c <= F) {
            b *= 2;
            c *= 2;
            if (t.length() == 0) {
                t = "2 D 2 D";
            } else {
                t += " 2 D 2 D";
            }
        } else {
            break;
        }
    }
    if (a == D && b == E && c == F) {
        flag = true;
    }
    return t;
}


int main() {
    int x[3], y[3];
    for (int i = 0; i < 3; i++) {
        cin >> x[i];
    }
    cin >> D >> E >> F;
    vector<int> v{0, 1, 2};
    string best = string(100, 'a');
    do {
        string t = sovle(x[v[0]], x[v[1]], x[v[2]]);
        int id[3];
        for (int i = 0; i < 3; i++) {
            id[i] = v[i];
        }
        string s = "";
        if (id[0] != 0 && id[1] != 1) {
            s = "1 C";
            swap(id[0], id[1]);
        }
        if (id[0] != 0 && id[2] != 2) {
            s = "1 B";
            swap(id[0], id[2]);
        }
        if (id[1] != 1) {
            if (s.length() == 0) {
                s = "1 A";
            } else {
                s += " 1 A";
            }
        }
        if (s.length() == 0) {
            if (flag) {
                if (best.length() < t.length()) {
                    best = t;
                }
            }
        } else {
            if (flag) {
                if (t.length() == 0) {
                    if (best.length() > s.length()) {
                        best = s;
                    }
                } else {
                    if (best.length() < t.length() + s.length()) {
                        best = s + " " + t;
                    }
                }
            }
        }
    } while (next_permutation(v.begin(), v.end()));
    if (best.length() == 100) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        cout << best << "\n";
    }
    return 0;
}
0