結果

問題 No.2213 Neq Move
ユーザー jianglyjiangly
提出日時 2023-02-10 21:50:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 198,672 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 22:59:19
合計ジャッジ時間 2,505 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    
    if (a > b) {
        std::swap(a, b);
        std::swap(c, d);
    }
    
    int ans = 0;
    if (c > d) {
        if (c < a) {
            std::cout << 1 + c + 1 + d << "\n";
            return;
        }
        b = 0;
        ans++;
        std::swap(a, b);
        std::swap(c, d);
    }
    
    if (a <= c && b <= d) {
        ans += c - a;
    } else {
        ans += c + 1;
        if (a == 1) {
            ans++;
        }
    }
    if (b <= d) {
        ans += d - b;
    } else {
        ans += d + 1;
    }
    
    std::cout << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}
0