結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
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,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/istream:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/sstream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/complex:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ccomplex:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54,
         次から読み込み:  main.cpp:1:
メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]’ 内,
    inlined from ‘int main()’ at main.cpp:39:13:
/usr/local/gcc7/include/c++/12.2.0/ostream:202:25: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:15:8: 備考: ‘ans’ はここで定義されています
   15 |     ll 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(){
    ll x,y,z;
    cin >> x >> y >> z;
    char S,T;
    ll s,t;
    ll 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