結果

問題 No.859 路線A、路線B、路線C
ユーザー erbowlerbowl
提出日時 2020-04-25 23:30:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,324 bytes
コンパイル時間 1,986 ms
コンパイル使用メモリ 197,748 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 15:05:03
合計ジャッジ時間 2,634 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<ll> dis(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> dis[i];
    }
    pair<ll,ll> start,end;
    char t1,t2;
    ll tt1,tt2;
    std::cin >> t1>>tt1;
    std::cin >> t2>>tt2;
    
    start = {t1-'A',tt1};
    end = {t2-'A',tt2};
    if(start.first==end.first){
        std::cout << min({
            abs(start.second-end.second),
            
            min(start.second,dis[start.first]-start.second)+
            min(end.second,dis[end.first]-end.second)+
            min(dis[(start.first+1)%3],dis[(start.first+2)%3]),
            
            start.second+end.second-dis[start.first]+
            min(dis[(start.first+1)%3],dis[(start.first+2)%3])
        }) << std::endl;
    }else{
        std::cout <<
            min({
                start.second+
                end.second-1,
                
                dis[start.first]-start.second+1+
                dis[end.first]-end.second,
                
                start.second+
                dis[3-start.first-end.first]+
                dis[end.first]-end.second,
                
                dis[start.first]-start.second+
                dis[3-start.first-end.first]+
                end.second
            })
        << std::endl;
    }

}

0