結果
| 問題 | 
                            No.1034 テスターのふっぴーさん
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-04-26 20:38:15 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,043 bytes | 
| コンパイル時間 | 728 ms | 
| コンパイル使用メモリ | 79,104 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-18 08:27:34 | 
| 合計ジャッジ時間 | 1,872 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 
struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
// } fio;
} ;
signed main(){
	cout<<fixed<<setprecision(10);
	
	
	int Q;
	
	cin>>Q;
	
	for(int _ = 0; _ < Q; _++){
		int N, I, J;
		int a, b, c, d, e;
		int ans = 0;
		
		cin>>N>>I>>J;
		
		a = I;
		b = N - 1 - J;
		c = N - 1 - I;
		d = J;
		
		e = min(min(a, b), min(c, d));
		
		ans = 4 * (N - e) * e;
		
		//cout<<e<<" "<<ans<<endl;
		
		if(a == e) {
			ans += (N - e*2 - 1) * 0;
			ans += J - e;
		} else if(b == e) {
			ans += (N - e*2 - 1) * 1;
			ans += I - e;
		} else if(c == e) {// cout<<"<>"<<endl;
			ans += (N - e*2 - 1) * 2;
			ans += N - 1 - J - e;
		} else {
			ans += (N - e*2 - 1) * 3;
			ans +=  N - 1 - I - e;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}