結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-08-10 01:54:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,320 bytes |
| コンパイル時間 | 695 ms |
| コンパイル使用メモリ | 84,272 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-19 16:12:40 |
| 合計ジャッジ時間 | 1,249 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | for (int i = 0; i < N; i++) scanf("%lld", ls + i), ls[i]--;
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:49:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%s%lld%s%lld", s0, &t0, s1, &t1);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 859.cc: No.859 路線A、路線B、路線C - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int N = 3;
/* typedef */
typedef long long ll;
/* global variables */
/* subroutines */
inline void setmin(ll &a, ll b) { if (a > b) a = b; }
/* main */
int main() {
ll ls[N];
for (int i = 0; i < N; i++) scanf("%lld", ls + i), ls[i]--;
char s0[4], s1[4];
ll t0, t1;
scanf("%s%lld%s%lld", s0, &t0, s1, &t1);
int r0 = s0[0] - 'A', r1 = s1[0] - 'A';
t0--, t1--;
if (t0 > t1) swap(t0, t1);
ll ans = 0;
if (r0 == r1) {
int q0 = (r0 + 1) % N, q1 = (r0 + 2) % N;
ans = t1 - t0;
setmin(ans, t0 + 1 + min(ls[q0], ls[q1]) + 1 + (ls[r0] - t1));
}
else {
int q0;
for (q0 = 0; q0 == r0 || q0 == r1; q0++);
ans = t0 + 1 + t1;
setmin(ans, (ls[r0] - t0) + 1 + (ls[r1] - t1));
setmin(ans, t0 + 1 + ls[q0] + 1 + (ls[r1] - t1));
setmin(ans, (ls[r0] - t0) + 1 + ls[q0] + 1 + t1);
}
printf("%lld\n", ans);
return 0;
}
tnakao0123