結果
| 問題 | 
                            No.859 路線A、路線B、路線C
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kyuna
                         | 
                    
| 提出日時 | 2019-08-19 13:23:30 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 782 bytes | 
| コンパイル時間 | 500 ms | 
| コンパイル使用メモリ | 71,712 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-04 04:28:09 | 
| 合計ジャッジ時間 | 1,196 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 10 WA * 2 | 
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
    vector<long long> c(3);
    for (long long &ci: c) cin >> ci;
    char s0, s1; long long t0, t1;
    cin >> s0 >> t0 >> s1 >> t1; s0 -= 'A', s1 -= 'A';
    if (s0 == s1) {
        swap(c[0], c[s0]);
        if (t0 > t1) swap(t0, t1);
        long long ans = min(t1 - t0, t0 + min(c[1], c[2]) + c[0] - t1);
        cout << ans << endl;
    } else {
        long long x = c[s0], y = c[s1], z = c[6 - s0 - s1];
        long long ans = min({
            t0 + t1 - 1, x - t0 + y - t1 + 1,
            t0 + z + t1 - y, x - t0 + z + t1
        });
        cout << ans << endl;
    }
    return 0;
}
            
            
            
        
            
kyuna