結果

問題 No.2213 Neq Move
ユーザー maksimmaksim
提出日時 2023-02-10 22:30:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 163,772 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 23:42:44
合計ジャッジ時間 1,918 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;cin>>t;
    while(t--)
    {
        int a,b,c,d;cin>>a>>b>>c>>d;
        int ans=0;
        if(a>c) {a=0;++ans;}
        if(b>d) {b=0;++ans;}
        if(a==0 && b==0)
        {
            cout<<c+d+ans<<'\n';continue;
        }
        else if(a==0)
        {
            if(d>c) {cout<<ans+d-b+c<<'\n';continue;}
            else {cout<<ans+1+c+d+(b==1)<<'\n';continue;}
        }
        else if(b==0)
        {
            if(c>d) {cout<<ans+d-a+c<<'\n';continue;}
            else {cout<<ans+1+c+d+(a==1)<<'\n';continue;}
        }
        else if(((a>b)^(c>d))==1)
        {
            cout<<max(1+c+d-b,1+d+c-a)<<'\n';continue;
        }
        else
        {
            cout<<c+d-a-b<<'\n';continue;
        }
    }
    return 0;
}
0