結果

問題 No.966 引き算をして門松列(その1)
ユーザー kya_skikya_ski
提出日時 2020-01-13 20:59:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,437 bytes
コンパイル時間 2,708 ms
コンパイル使用メモリ 197,744 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 13:50:25
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
void num(int n) { cout << n << endl; }
int mid(int a, int b,int c) { return a+b+c-min({a,b,c})-max({a,b,c}); }
void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < c) swap(a, c);
    if (a != b && b != c && c != a) {
        if (mid(a,b,c)==a||mid(a,b,c)==c) { cout << 0 << endl; return; }
        if (b == 2 && c == 1) { cout << -1 << endl; return; }
        cout << abs(a-b)+1 << endl; return;
    }
    if (a == c && a != b) {
        if (a == 2 && b == 1) { cout << -1 << endl; return; }
        if (b+1 == a) { cout << 2 << endl; return; }
        if (b < a) { cout << 1 << endl; return; }
        if (a == 1) { num(-1); return; }
        num(1); return;
    }
    if (a == b && b != c) {
        if (c == 1 && a == 2) { num(-1); return; }
        if (a-c == 1) { num(2); return; }
        num(1); return;
    }
    if (a != b && b == c) {
        if (b != 1) { num(1); return; }
        num(-1); return;
    }
    if (a == b && b == c) {
        if (a < 3) { num(-1); return; }
        num(3); return;
    }
}

int main() {
    int Q;
    cin >> Q;
    while (Q--) solve();
    return 0;
}
0