結果

問題 No.2213 Neq Move
ユーザー maksim
提出日時 2023-02-10 22:30:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 167,116 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 16:38:55
合計ジャッジ時間 1,778 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

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