結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
rodea
|
| 提出日時 | 2020-10-12 15:52:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,092 bytes |
| コンパイル時間 | 1,556 ms |
| コンパイル使用メモリ | 117,780 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 18:02:53 |
| 合計ジャッジ時間 | 2,624 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 6 |
ソースコード
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}
constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
#define all(a) (a).begin(), (a).end()
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll x, y, z; cin>>x>>y>>z;
vector<pair<char, ll>> st(2);
cin>>st[0].first>>st[0].second>>st[1].first>>st[1].second;
sort(all(st));
vector<char> s(2);
vector<ll> t(2);
for(int i=0; i<2; i++){
tie(s[i], t[i]) = st[i];
}
ll ans = 0;
ll tmi = min(t[0], t[1]), tma = max(t[0], t[1]);
if(s[0] == 'A'){
if(s[1] == 'A'){
ans = min({tma - tmi, tmi + (x - tma) + y, tmi + (x - tma) + z});
}
else if(s[1] == 'B'){
ans = min({(x - t[0]) + (y - t[1]), t[0] + t[1] - 1, t[0] + z + (y - t[1])});
}
else{
ans = min({(x - t[0]) + (z - t[1]), t[0] + y + (z - t[1]), t[0] + t[1] - 1});
}
}
else if(s[0] == 'B'){
if(s[1] == 'B'){
ans = min({tma - tmi, tmi + (y - tma) + x, tmi + (y - tma) + z});
}
else{
ans = min({(y - t[0]) + (z - t[1]), t[0] + x + (z - t[1]), t[0] + t[1] - 1});
}
}
else{
ans = min({tma - tmi, tmi + (z - tma) + x, tmi + (z - tma) + y});
}
cout << ans << endl;
return 0;
}
rodea