結果

問題 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,423 ms
コンパイル使用メモリ 167,384 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 05:53:36
合計ジャッジ時間 1,974 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
In member function '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:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:15:8: note: 'ans' was declared here
   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