結果

問題 No.1034 テスターのふっぴーさん
コンテスト
ユーザー TonalidadeHidrica
提出日時 2020-04-24 21:32:34
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,025 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,360 ms
コンパイル使用メモリ 209,076 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-09 16:54:50
合計ジャッジ時間 2,697 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int tq; scanf("%d", &tq);
	REP(iq, tq){
		ll n, y, x; scanf("%lld%lld%lld", &n, &y, &x);
		ll a = min({y, n-1-y, x, n-1-x});
		ll b = n-2*a-1, c = n-1-a;
		ll ans = 4*(n-1)*a - 4*a*(a-1);
		if(y == a) {
			ans += b * 0 + x-a;
		} else if(x == c){
			ans += b * 1 + y-a;
		} else if(y == c){
			ans += b * 2 + c-x;
		} else {
			ans += b * 3 + c-y;
		}
		printf("%lld\n", ans);
	}
}
0