結果

問題 No.859 路線A、路線B、路線C
ユーザー totori_nyaatotori_nyaa
提出日時 2019-08-09 21:54:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,407 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 165,224 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 17:49:40
合計ジャッジ時間 2,341 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

signed main(){
    //cout << setprecision(12) ;
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll x,y,z;
    cin>>x>>y>>z;
    string s1,s2; ll t1,t2;
    cin>>s1>>t1>>s2>>t2;
    ll ans = 1e18;
    
    

    if(s1==s2){
        if(s1=="B") swap(x,y);
        if(s1=="C") swap(z,x);
        ans = abs(t2-t1);
        ll d1 = t1 + min(y,z) + x-t2;
        ll d2 = x-t1  + min(y,z) + t2-1;
        ans = min(ans,min(d1,d2));
        cout<<ans<<endl;
    }
    else {
        ll a,b,c;
        if(s1=="A"){
            a=x;
            if(s2=="B"){
                b=y;
                c=z;
            }
            else {
                b=z,c=y;
            }
        }
        else if(s1=="B"){
            a=y;
            if(s2=="A"){
                b=x;
                c=z;
            }
            else {
                b=z;
                c=x;
            }
        }
        else {
            a=z;
            if(s2=="A"){
                b=x;
                c=y;
            }
            else {
                b=y;
                c=x;
            }
        }

        ll d1 = t1 + t2-1;
        ll d2 = t1 + c + b - t2;
        ll d3 = a - t1 + b-t2;
        ll d4 = a-t1 +1 + c + t2-1;
        //cerr<<d1<<" "<<d2<<" "<<d3<<" "<<d4<<endl;
        ans = min(min(d1,d2),min(d3,d4));
        cout<<ans<<endl;
    }

}
0