結果

問題 No.2213 Neq Move
ユーザー SSRSSSRS
提出日時 2023-02-10 21:48:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 164,644 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 22:57:54
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A < B){
      swap(A, B);
      swap(C, D);
    }
    if (C > D){
      if (A <= C){
        if (B <= D){
          cout << (C - A) + (D - B) << endl;
        } else {
          cout << (C - A) + 1 + D << endl;
        }
      } else {
        if (B > 1){
          cout << 3 + (C - 1) + D << endl;
        } else {
          cout << 4 + (C - 1) + D << endl;
        }
      }
    } else {
      if (B <= D){
        cout << 1 + C + (D - B) << endl;
      } else {
        cout << 3 + C + (D - 1) << endl;
      }
    }
  }
}
0