結果

問題 No.966 引き算をして門松列(その1)
ユーザー uzzyuzzy
提出日時 2020-01-13 21:32:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,533 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 165,020 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 15:23:36
合計ジャッジ時間 2,035 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int T;
	cin >> T;

	rep(i, T) {
		int a, b, c;
		cin >> a >> b >> c;

		int saishou = -1;

		if (a == b && b == c) {
			if (a > 2) saishou = 3;
		}
		else if (a == b) {
			if (a > 2) {
				if (a == c + 1) saishou = 2;
				else saishou = 1;
			}
			else if (a == 2) {
				if (c > 2) saishou = 1;
			}
		}
		else if (b == c) {
			if (c > 2) {
				if (a + 1 == c) saishou = 2;
				else saishou = 1;
			}
			else if (c == 2) {
				if (a > 2) saishou = 1;
			}
		}
		else if (a == c) {
			if (a > 2) {
				if (a == b + 1) saishou = 2;
				else saishou = 1;
			}
			else if (a == 2) {
				if (b > 2) saishou = 1;
			}
		}
		else if (a < b && b > c) saishou = 0;
		else if (a > b && b < c) saishou = 0;
		else if (a < b) {
			if (a != 1) saishou = min(b - a, c - b) + 1;
			else if (b != 2) saishou = c - b + 1;
		}
		else {
			if (c != 1) saishou = min(a - b, b - c) + 1;
			else if (b != 2) saishou = a - b + 1;
		}

		co(saishou);
	}


	Would you please return 0;
}
0