結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
i_am_nicolen_22
|
| 提出日時 | 2019-08-09 23:24:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 2,651 bytes |
| コンパイル時間 | 1,294 ms |
| コンパイル使用メモリ | 162,836 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 15:52:28 |
| 合計ジャッジ時間 | 1,880 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int main(){
ll x,y,z;
string s1,s2;
ll t1,t2;
cin>>x>>y>>z;
cin>>s1>>t1>>s2>>t2;
if(s1==s2 && s1=="A"){
cout<<min({abs(t1-t2),t1-1+y+(x-t2)+1,t1-1+z+(x-t2)+1,t2-1+y+(x-t1)+1,t2-1+z+(x-t1)+1})<<endl;
}
else if(s1==s2 && s1=="B"){
cout<<min({abs(t1-t2),t1-1+x+(y-t2)+1,t1-1+z+(y-t2)+1,t2-1+x+(y-t1)+1,t2-1+z+(y-t1)+1})<<endl;
}
else if(s1==s2 && s1=="C"){
cout<<min({abs(t1-t2),t1-1+x+(z-t2)+1,t1-1+y+(z-t2)+1,t2-1+x+(z-t1)+1,t2-1+y+(z-t1)+1})<<endl;
}
else if((s1=="A" && s2=="C") ){
cout<<min({t1-1+t2-1+1,x-t1+z-t2+1, t1-1+1+y+z-t2,t2-1+1+y+x-t1})<<endl;
}
else if(s1=="C" && s2=="A"){
cout<<min({t1-1+t2-1+1,z-t1+x-t2+1, t1-1+1+y+x-t2,t2-1+1+y+z-t1})<<endl;
}
else if((s1=="A" && s2=="B") ){
cout<<min({t1-1+t2-1+1,x-t1+y-t2+1,t1-1+1+z+y-t2,t2-1+1+z+x-t1})<<endl;
}
else if(s1=="B" && s2=="A"){
cout<<min({t1-1+t2-1+1,y-t1+x-t2+1,t1-1+1+z+x-t2,t2-1+1+z+y-t1})<<endl;
}
else if((s1=="B" && s2=="C") ){
cout<<min({t1-1+t2-1+1,y-t1+z-t2+1,t1-1+1+x+z-t2,t2-1+1+x+y-t1})<<endl;
}
else if(s1=="C" && s2=="B"){
cout<<min({t1-1+t2-1+1,z-t1+y-t2+1,t1-1+1+x+y-t2,t2-1+1+x+z-t1})<<endl;
}
return 0;
}
i_am_nicolen_22