結果

問題 No.859 路線A、路線B、路線C
ユーザー けーむけーむ
提出日時 2020-03-27 11:58:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,825 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 170,540 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 16:22:13
合計ジャッジ時間 4,033 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    vector<ll> xyz(3);
    rep(i, 3) cin >> xyz[i];
    char s0, s1;
    ll t0, t1;
    cin >> s0 >> t0 >> s1 >> t1;
    // 0:a1, 1:ax, 2:b1, 3:by, 4:c1, 5:cz, 6:st, 7:en
    vector<vector<ll>> d(8, vector<ll>(8, inf));
    rep(i, 8) d[i][i] = 0;
    d[0][1] = xyz[0] - 1;
    d[0][2] = 1;
    d[0][4] = 1;
    d[1][0] = xyz[0] - 1;
    d[1][3] = 1;
    d[1][5] = 1;
    d[2][0] = 1;
    d[2][3] = xyz[1] - 1;
    d[2][4] = 1;
    d[3][1] = 1;
    d[3][2] = xyz[1] - 1;
    d[3][5] = 1;
    d[4][0] = 1;
    d[4][2] = 1;
    d[4][5] = xyz[2] - 1;
    d[5][1] = 1;
    d[5][3] = 1;
    d[5][4] = xyz[2] - 1;
    d[6][(s0 - 'A') * 2] = t0 - 1;
    d[(s0 - 'A') * 2][6] = t0 - 1;
    d[6][(s0 - 'A') * 2 + 1] = xyz[s0 - 'A'] - t0;
    d[(s0 - 'A') * 2 + 1][6] = xyz[s0 - 'A'] - t0;
    d[7][(s1 - 'A') * 2] = t1 - 1;
    d[(s1 - 'A') * 2][7] = t1 - 1;
    d[7][(s1 - 'A') * 2 + 1] = xyz[s1 - 'A'] - t1;
    d[(s1 - 'A') * 2 + 1][7] = xyz[s1 - 'A'] - t1;
    // rep(i, 8) rep(j, 8) printf("%lld%s", d[i][j], (j == 7) ? "\n" : " ");printf("\n");
    rep(i, 8) rep(j, 8) rep(k, 8) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
    cout << d[6][7] << endl;
    // rep(i, 8) rep(j, 8) printf("%lld%s", d[i][j], (j == 7) ? "\n" : " ");
    return 0;
}
0