結果

問題 No.3796 Fanmade Tile Distance
コンテスト
ユーザー tnakao0123
提出日時 2026-11-17 10:25:50
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 85 ms / 2,000 ms
+ 807µs
コード長 627 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 214 ms
コンパイル使用メモリ 56,172 KB
実行使用メモリ 9,836 KB
最終ジャッジ日時 2026-11-17 10:25:55
合計ジャッジ時間 4,653 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3796.cc:  No.3796 Fanmade Tile Distance - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

int calc(int x, int a) {
  return (x >= 0) ? x / a : (x + 1) / a - 1;
}

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int a, b, sx, sy, tx, ty;
    scanf("%d%d%d%d%d%d", &a, &b, &sx, &sy, &tx ,&ty);

    int si = calc(sx, a);
    int sj = calc(sy, b);
    int ti = calc(tx, a);
    int tj = calc(ty, b);

    printf("%d\n", abs(ti - si) + abs(tj - sj));
  }

  return 0;
}
0