結果
| 問題 | 
                            No.859 路線A、路線B、路線C
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2019-08-10 01:52:04 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,391 bytes | 
| コンパイル時間 | 638 ms | 
| コンパイル使用メモリ | 83,832 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 16:12:35 | 
| 合計ジャッジ時間 | 1,184 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 WA * 2 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |   for (int i = 0; i < N; i++) scanf("%d", ls + i), ls[i]--;
      |                               ~~~~~^~~~~~~~~~~~~~
main.cpp:52:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |   scanf("%s%d%s%d", 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;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;
/* global variables */
/* subroutines */
inline void setmin(int &a, int b) { if (a > b) a = b; }
/* main */
int main() {
  int ls[N];
  for (int i = 0; i < N; i++) scanf("%d", ls + i), ls[i]--;
  char s0[4], s1[4];
  int t0, t1;
  scanf("%s%d%s%d", s0, &t0, s1, &t1);
  int r0 = s0[0] - 'A', r1 = s1[0] - 'A';
  t0--, t1--;
  if (t0 > t1) swap(t0, t1);
  int 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("%d\n", ans);
  return 0;
}
            
            
            
        
            
tnakao0123