結果

問題 No.859 路線A、路線B、路線C
ユーザー RTnFRTnF
提出日時 2019-08-09 21:56:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,041 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 199,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 17:51:22
合計ジャッジ時間 2,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x, y, z;
    cin >> x >> y >> z;
    char s1, s2;
    ll t1, t2;
    cin >> s1 >> t1 >> s2 >> t2;
    if(s1 == s2){
        if(t1 > t2) swap(t1, t2);
        ll r1 = x, r2 = y, r3 = z;
        if(s1 == 'B') swap(r1, r2);
        if(s1 == 'C') swap(r1, r3);
        cout << min({t2-t1, t1+r3+r1-t2, t1+r3+r1-t2}) << endl;
    }else{
        ll r1 = x, r2 = y, r3 = z;
        if(s1 == 'A'){
            if(s2 == 'C')
                swap(r2, r3);
        }
        if(s1 == 'B'){
            swap(r1, r2);
            if(s2 == 'C')
                swap(r2, r3);
        }
        if(s1 == 'C'){
            swap(r1, r3);
            if(s2 == 'A')
                swap(r2, r3);
        }
        dump(t1+t2-1, r1-t1+r2-t2+1, t1+r3+r2-t2, r1-t1+r3+t2);
        cout << min({t1+t2-1, r1-t1+r2-t2+1, t1+r3+r2-t2, r1-t1+r3+t2}) << endl;
    }
    return 0;
}
0