結果

問題 No.859 路線A、路線B、路線C
ユーザー kappybarkappybar
提出日時 2020-04-08 23:36:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 164,884 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 11:13:15
合計ジャッジ時間 2,611 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 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 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:39:13: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   39 |     cout << ans << endl;
      |             ^~~
main.cpp:15:9: 備考: ‘ans’ はここで定義されています
   15 |     int ans;
      |         ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
using pp = pair<bool,bool>;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    char S,T;
    int s,t;
    int ans;
    cin >> S >> s >> T >> t;
    if(S == 'A' && T =='B'){
        ans = min({s+t-1,x-s+y-t+1,t+z+x-s,s+z+y-t});
    }else if(S == 'B' && T == 'A'){
        ans = min({s+t-1,x-t+y-s+1,s+z+x-t,t+z+y-s});
    }else if(S == 'B' && T == 'C'){
        ans = min({s+t-1,y-s+z-t+1,s+x+z-t,y-s+x+t});
    }else if(S == 'C' && T == 'B'){
        ans = min({s+t-1,y-t+z-s+1,t+x+z-s,y-t+x+s});
    }else if(S == 'A' && T == 'C'){
        ans = min({s+t-1,x-s+z-t+1,s+y+z-t,x-s+y+t});
    }else if(S =='C' && T == 'A'){
        ans = min({s+t-1,x-t+z-s+1,t+y+z-s,x-t+y+s});
    }else if(S == 'C' && T =='C'){
        if(s > t) swap(s,t);
        ans = min({t-s,s+z-t+x,s+z-t+y});
    }else if(S == 'B' && T =='B'){
        if(s > t) swap(s,t);
        ans = min({t-s,s+y-t+x,s+y-t+z});
    }else if(S == 'A' && T =='A'){
        if(s > t) swap(s,t);
        ans = min({t-s,s+x-t+y,s+x-t+z});
    }
    cout << ans << endl;
    return 0;
}
0