結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
i_mrhj
|
| 提出日時 | 2019-08-10 18:09:01 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,625 bytes |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 30,976 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 17:14:23 |
| 合計ジャッジ時間 | 916 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 3 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)
void
swap(int* a, int* b){
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
return;
}
int
main(int argc, char *argv[])
{
int x, y, z;
scanf("%d %d %d\n", &x, &y, &z);
char s[2], ctmp; int t[2], tmp;
scanf("%c", &s[0]);
scanf("%d\n", &t[0]);
scanf("%c", &s[1]);
scanf("%d", &t[1]);
if (s[0] > s[1]) {
ctmp = s[0];
tmp = t[0];
s[0] = s[1];
t[0] = t[1];
s[1] = ctmp;
t[1] = tmp;
}
int a, b, c, d, e, f; int ans;
if (s[0] == s[1]) {
int m = Min(t[0], t[1]);
int M = Max(t[0], t[1]);
a = M - m;
if (s[0] == 'A') {
b = m + M - x + y;
c = m + M - x + z;
ans = Min(a, Min(b, c));
}
if (s[0] == 'B') {
b = m + M - y + x;
c = m + M - y + z;
ans = Min(a, Min(b, c));
}
if (s[0] == 'C') {
b = m + M - z + x;
c = m + M - z + y;
ans = Min(a, Min(b, c));
}
} else {
if (s[1] == 'B') swap(&y, &z);
if (s[0] == 'B') {
int temp = x;
x = y; y = z; z = temp;
}
a = t[0] + t[1] - 1;
b = x - t[0] + 1 + z - t[1];
c = t[0] - 1 + y + z - t[1] + 1;
d = x - t[0] + y + t[1];
ans = Min(a, Min(b, Min(c, d)));
}
printf("%d\n", ans);
return 0;
}
i_mrhj