結果

問題 No.859 路線A、路線B、路線C
ユーザー Bwambocos
提出日時 2019-08-09 21:35:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,839 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 168,728 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 11:27:41
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
int main()
{
LL x, y, z, t0, t1;
char S0, S1;
in >> x >> y >> z >> S0 >> t0 >> S1 >> t1;
if (S0 > S1)
{
std::swap(S0, S1);
std::swap(t0, t1);
}
LL ans = 1145148101919364;
if (S0 == 'A' && S1 == 'A')
{
LL res1 = std::abs(t0 - t1);
LL res2 = t0 + (y - 1) + (x - t1) + 1;
LL res3 = t1 + (y - 1) + (x - t0) + 1;
LL res4 = t0 + (z - 1) + (x - t1) + 1;
LL res5 = t1 + (z - 1) + (x - t0) + 1;
ans = std::min({ res1,res2,res3,res4,res5 });
}
if (S0 == 'A' && S1 == 'B')
{
LL res1 = t0 + (t1 - 1);
LL res2 = (x - t0) + (y - t1) + 1;
LL res3 = t0 + (z - 1) + (y - t1) + 1;
LL res4 = (x - t0) + 1 + z + (t1 - 1);
ans = std::min({ res1,res2,res3,res4 });
}
if (S0 == 'A' && S1 == 'C')
{
LL res1 = t0 + (t1 - 1);
LL res2 = (x - t0) + 1 + (z - t1);
LL res3 = t0 + y + (z - t1);
LL res4 = (x - t0) + 1 + y + (t1 - 1);
ans = std::min({ res1,res2,res3,res4 });
}
if (S0 == 'B' && S1 == 'B')
{
LL res1 = std::abs(t0 - t1);
LL res2 = t0 + (x - 1) + (y - t1) + 1;
LL res3 = t1 + (x - 1) + (y - t0) + 1;
LL res4 = t0 + (z - 1) + (y - t1) + 1;
LL res5 = t1 + (z - 1) + (y - t0) + 1;
ans = std::min({ res1,res2,res3,res4,res5 });
}
if (S0 == 'B' && S1 == 'C')
{
LL res1 = t0 + (t1 - 1);
LL res2 = (y - t0) + (z - t1) + 1;
LL res3 = t0 + (x - 1) + (z - t1) + 1;
LL res4 = (y - t0) + 1 + x + (t1 - 1);
ans = std::min({ res1,res2,res3,res4 });
}
if (S0 == 'C' && S1 == 'C')
{
LL res1 = std::abs(t0 - t1);
LL res2 = t0 + (y - 1) + (z - t1) + 1;
LL res3 = t1 + (y - 1) + (z - t0) + 1;
LL res4 = t0 + (x - 1) + (z - t1) + 1;
LL res5 = t1 + (x - 1) + (z - t0) + 1;
ans = std::min({ res1,res2,res3,res4,res5 });
}
out << ans << std::endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0