結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
sumochiP
|
| 提出日時 | 2019-08-09 22:45:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,363 bytes |
| コンパイル時間 | 1,511 ms |
| コンパイル使用メモリ | 168,912 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 14:51:15 |
| 合計ジャッジ時間 | 1,948 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function 'lint abc_to_xyz(lint, lint, lint, std::string)':
main.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type]
27 | }
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
lint abc_to_xyz(lint x,lint y,lint z,string abc){
if(abc=="A")
return x;
if (abc == "B")
return y;
if (abc == "C")
return z;
}
int main()
{
lint x, y,z;
cin >> x >> y >> z;
lint ans, tmp;
string s0, s1;
lint t0, t1;
cin >> s0 >> t0;
cin >> s1 >> t1;
lint i = t0;
lint j = t1;
lint s = abc_to_xyz(x, y, z, s0); //スタート路線の長さ
lint g = abc_to_xyz(x, y, z, s1); //ゴール路線の長さ
lint l = i - 1, r = s - i;
lint goleft = min(l, r + min(min(x,y),z));
lint goright = min(r, l + min(min(x, y), z));
ans = min(goleft + j, goright + g - j + 1);
if (s0 == s1)
{
ans = min(ans,abs(j - i));
}
cout
<< ans << "\n";
return 0;
}
sumochiP