結果
| 問題 | 
                            No.859 路線A、路線B、路線C
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-08-09 22:12:16 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,164 bytes | 
| コンパイル時間 | 1,974 ms | 
| コンパイル使用メモリ | 161,292 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-19 12:10:11 | 
| 合計ジャッジ時間 | 2,050 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int, int>> vec[10];
signed main(){
    int x, y, z;
    cin >> x >> y >> z;
    int memo[3] = {x, y, z};
    pair<char, int> s, t;
    cin >> s.first >> s.second;
    cin >> t.first >> t.second;
    int si = s.first-'A';
    int ti = t.first-'A';
    int vi;
    if(si != 1 && ti != 1) vi = 1;
    if(si != 2 && ti != 2) vi = 2;
    if(si != 0 && ti != 0) vi = 0;
    int a1 = s.second-1 + t.second-1 + 1;
    int a2 = memo[si] - s.second  + memo[ti] - t.second + 1;
    int a3 = s.second-1 + 1 + memo[vi] + memo[ti]-t.second;
    int a4 = memo[si]-s.second + 1 + memo[vi] + t.second-1;
    if(s.first != t.first){
        cout << min(a1, min(a2, min(a3, a4))) << endl;
    }else{
        int x, y;
        x = min(s.second, t.second);
        y = max(s.second, t.second);
        int a5 = y-x;
        int a6, a7, a8;
        a6 = a7 = a8 = LLONG_MAX;
        if(si != 0)  a6 = memo[si]-y+x-1+1+x;
        if(si != 1)  a7 = memo[si]-y+x-1+1+y;
        if(si != 2)  a8 = memo[si]-y+x-1+1+z;
        cout << min(a5, min(a6, min(a7, a8))) << endl;
    }
    return 0;
}