結果

問題 No.966 引き算をして門松列(その1)
ユーザー dekomori_sanaedekomori_sanae
提出日時 2020-01-13 21:11:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,510 bytes
コンパイル時間 1,647 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 13:48:16
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll q;
    cin >> q;

    rep(loop, q) {
        ll a, b, c;
        cin >> a >> b >> c;
        if(a <= 2 && b <= 2 && c <= 2) {  // すべて2以下はダメ
            out(-1);
        }
        else if( (b == 2 && a == 1) || (b == 2 && c == 1) ) {
            out(-1);
        }
        else if(a == b && b == c && c == a) {  // すべて同じ3以上の数のときは3
            out(3);
        }
        else if(a != b && b != c && c != a) {
            if(0 < (b-a)*(b-c)) {
                out(0);
            }
            else {
                out(min({abs(a-b), abs(b-c), abs(c-a)}));
            }
        }
        else {
            out(min({abs(a-b), abs(b-c), abs(c-a)}));
        }
    }

    re0;
}
0