結果

問題 No.2213 Neq Move
ユーザー lddlinanlddlinan
提出日時 2023-03-11 18:37:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,193 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 83,944 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 10:12:19
合計ジャッジ時間 1,611 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;



int main() {
    int n, i, a, b, c,d, t, r;
    int tc; scanf("%d", &tc); while(tc) { tc--;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        if (c>d) {
            t=c;c=d; d=t;
            t=a; a=b; b=t;
        }
        r=0;
        if (a<b) {
            if (b<=d) {
                r+=d-b;
                if (a<=c) r+=c-a;
                else {
                    r+=(c+1);
                }
            } else {
                r=1;
                if (a==1) r++;
                r++;
                r+=d;
                r+=c;
            }
        } else {
            if (b<=d) {
                r=1;
                r+=(d-b);
                r+=c;
            } else {
                r=1;
                if (a==1) r++;
                r+=d; r+=(c+1);
            }
        }
        printf("%d\n", r);
    }
    return 0;
}
0