結果

問題 No.859 路線A、路線B、路線C
ユーザー erbowl
提出日時 2020-04-25 23:42:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,333 bytes
コンパイル時間 2,622 ms
コンパイル使用メモリ 194,564 KB
最終ジャッジ日時 2025-01-10 01:44:51
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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+dis[start.first]-end.second+
            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