結果

問題 No.859 路線A、路線B、路線C
ユーザー sumochiPsumochiP
提出日時 2019-08-09 22:45:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,363 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 164,944 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 21:02:39
合計ジャッジ時間 2,211 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘lint abc_to_xyz(lint, lint, lint, std::string)’ 内:
main.cpp:27:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   27 | }
      | ^

ソースコード

diff #

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

lint abc_to_xyz(lint x,lint y,lint z,string abc){
    if(abc=="A")
        return x;
    if (abc == "B")
        return y;
    if (abc == "C")
        return z;
}

int main()
{
    lint x, y,z;
    cin >> x >> y >> z;

    lint ans, tmp;

    string s0, s1;
    lint t0, t1;
    cin >> s0 >> t0;
    cin >> s1 >> t1;
    lint i = t0;
    lint j = t1;
    lint s = abc_to_xyz(x, y, z, s0); //スタート路線の長さ
    lint g = abc_to_xyz(x, y, z, s1); //ゴール路線の長さ
    lint l = i - 1, r = s - i;
    lint goleft = min(l, r + min(min(x,y),z));
    lint goright = min(r, l + min(min(x, y), z));
    ans = min(goleft + j, goright + g - j + 1);
    


    if (s0 == s1)
    {
        ans = min(ans,abs(j - i));
    }

    cout
        << ans << "\n";

    return 0;
}
0