結果

問題 No.859 路線A、路線B、路線C
ユーザー uchiiiiuchiiii
提出日時 2019-08-09 22:55:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 172,640 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 21:29:20
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main(){
	ll x,y,z; cin >> x >> y >> z;
	char s1,s2; ll t1, t2; cin >> s1 >> t1 >> s2 >> t2;
	ll seq1[3], seq2[3];
	map<char, ll> mp;
	mp['A'] = x;
	mp['B'] = y;
	mp['C'] = z;

	if(s1==s2){
		ll ans = abs(t1-t2);
		ll cur = min(t1,t2)-1;
		cur += mp[s1] - max(t1,t2);
		for(auto&& w: mp){
			if(w.first != s1) chmin(ans, cur + w.second);
		}
		cout << ans << endl;
	}else{
		ll ans = LINF;
		{
			chmin(ans, t1-1+t2);
			chmin(ans, mp[s1]-t1+mp[s2]-t2+1);
		}
		{
			for(auto&& w:mp){
				chmin(ans, t1-1+mp[s2]-t2+1+w.second);
				chmin(ans, mp[s1]-t1+t2-1+1+w.second);
			}
		}
		cout << ans << endl;
	}
    return 0;
}
0