結果

問題 No.859 路線A、路線B、路線C
ユーザー kagasankagasan
提出日時 2019-10-08 18:50:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,047 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 162,716 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 01:11:24
合計ジャッジ時間 2,364 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 2 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 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll x, y, z;
ll L(char s, ll t){
	return t - 1;
}
ll R(char s, ll t){
	if(s == 'A')return x - t;
	if(s == 'B')return y - t;
	return z - t;
}

int main(){

	cin >> x >> y >> z;
	char s0, s1;
	ll t0, t1;
	cin >> s0 >> t0;
	cin >> s1 >> t1;
	ll ans = 1145141919810893;

	ll tmp = min(x, min(y, z)) - 1;
	chmin(ans, 2 + tmp + L(s0, t0) + R(s1, t1));
	chmin(ans, 2 + tmp + R(s0, t0) + L(s1, t1));
	chmin(ans, 1 + L(s0, t0) + L(s1, t1));
	chmin(ans, 1 + R(s0, t0) + R(s1, t1));
	if(s0 == s1)chmin(ans, abs(t0 - t1));

	cout << ans << endl;

    return 0;
}
0