Submission #54932476
Source Code Expand
Copy
#include <stdio.h>#include <inttypes.h>int64_t zettaiti(int64_t x) {return x < 0 ? -x : x;}int main(void) {int64_t Sx, Sy, Tx, Ty;int64_t xd, yd;if (scanf("%" SCNd64 "%" SCNd64, &Sx, &Sy) != 2) return 1;if (scanf("%" SCNd64 "%" SCNd64, &Tx, &Ty) != 2) return 1;xd = zettaiti(Sx - Tx);yd = zettaiti(Sy - Ty);if (xd <= yd) {printf("%" PRId64 "\n", yd);} else {int64_t Sx_2 = Sx;int64_t Tx_2 = Sx < Tx ? Tx - yd : Tx + xd;int64_t ans = 0;if (Sx_2 > Tx_2) {
#include <stdio.h> #include <inttypes.h> int64_t zettaiti(int64_t x) { return x < 0 ? -x : x; } int main(void) { int64_t Sx, Sy, Tx, Ty; int64_t xd, yd; if (scanf("%" SCNd64 "%" SCNd64, &Sx, &Sy) != 2) return 1; if (scanf("%" SCNd64 "%" SCNd64, &Tx, &Ty) != 2) return 1; xd = zettaiti(Sx - Tx); yd = zettaiti(Sy - Ty); if (xd <= yd) { printf("%" PRId64 "\n", yd); } else { int64_t Sx_2 = Sx; int64_t Tx_2 = Sx < Tx ? Tx - yd : Tx + xd; int64_t ans = 0; if (Sx_2 > Tx_2) { int64_t t = Sx_2; Sx_2 = Tx_2; Tx_2 = t; } if (Sx_2 < Tx_2) { if ((Sx_2 + Sy) % 2 != 0) { Sx_2++; ans++; } ans += (Tx_2 - Sx_2) / 2; } printf("%" PRId64 "\n", ans); } return 0; } /* 斜め方向に1移動する → 常にコスト1 縦方向に1移動する → 常にコスト1 横方向に1移動する → 座標によってコスト1だったり0だったりする 横のパターンは斜め移動しても変わらない */
Submission Info
Submission Time | |
---|---|
Task | C - Tile Distance 2 |
User | mikecat |
Language | C (gcc 12.2.0) |
Score | 0 |
Code Size | 1009 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 1760 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 350 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 0 ms | 1640 KB |
00_sample_01.txt | AC | 0 ms | 1624 KB |
00_sample_02.txt | AC | 0 ms | 1604 KB |
01_random_03.txt | AC | 0 ms | 1640 KB |
01_random_04.txt | WA | 0 ms | 1628 KB |
01_random_05.txt | WA | 0 ms | 1648 KB |
01_random_06.txt | AC | 0 ms | 1760 KB |
01_random_07.txt | AC | 0 ms | 1720 KB |
01_random_08.txt | AC | 0 ms | 1728 KB |
01_random_09.txt | AC | 0 ms | 1748 KB |
01_random_10.txt | WA | 0 ms | 1644 KB |
01_random_11.txt | WA | 0 ms | 1612 KB |
01_random_12.txt | AC | 1 ms | 1752 KB |
01_random_13.txt | AC | 0 ms | 1708 KB |
01_random_14.txt | AC | 0 ms | 1708 KB |
01_random_15.txt | AC | 0 ms | 1624 KB |
01_random_16.txt | AC | 0 ms | 1584 KB |
01_random_17.txt | AC | 0 ms | 1640 KB |
01_random_18.txt | WA | 0 ms | 1744 KB |
01_random_19.txt | WA | 0 ms | 1632 KB |
01_random_20.txt | WA | 0 ms | 1580 KB |
01_random_21.txt | WA | 0 ms | 1628 KB |
01_random_22.txt | AC | 0 ms | 1620 KB |
01_random_23.txt | WA | 0 ms | 1624 KB |
01_random_24.txt | AC | 0 ms | 1624 KB |
01_random_25.txt | WA | 0 ms | 1744 KB |
01_random_26.txt | AC | 0 ms | 1736 KB |
01_random_27.txt | WA | 0 ms | 1628 KB |
01_random_28.txt | AC | 0 ms | 1652 KB |
01_random_29.txt | WA | 0 ms | 1580 KB |
01_random_30.txt | AC | 0 ms | 1728 KB |
01_random_31.txt | WA | 0 ms | 1760 KB |
01_random_32.txt | WA | 0 ms | 1616 KB |
01_random_33.txt | AC | 0 ms | 1632 KB |
01_random_34.txt | WA | 0 ms | 1624 KB |
01_random_35.txt | AC | 0 ms | 1616 KB |
01_random_36.txt | AC | 0 ms | 1660 KB |
01_random_37.txt | AC | 0 ms | 1728 KB |
01_random_38.txt | AC | 0 ms | 1736 KB |
01_random_39.txt | AC | 0 ms | 1588 KB |
01_random_40.txt | AC | 0 ms | 1600 KB |
01_random_41.txt | AC | 0 ms | 1576 KB |
01_random_42.txt | AC | 0 ms | 1656 KB |
01_random_43.txt | AC | 1 ms | 1632 KB |
01_random_44.txt | WA | 0 ms | 1724 KB |
01_random_45.txt | AC | 0 ms | 1632 KB |
01_random_46.txt | AC | 1 ms | 1740 KB |
01_random_47.txt | AC | 0 ms | 1744 KB |
01_random_48.txt | AC | 0 ms | 1732 KB |