結果

問題 No.1034 テスターのふっぴーさん
ユーザー saswata desaswata de
提出日時 2020-04-24 22:05:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,905 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 164,980 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 03:21:19
合計ジャッジ時間 2,603 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define rep(it,a) for(auto it: a)
#define pb emplace_back
#define mp make_pair
#define vll vector<ll>
#define pll pair<ll,ll>
#define MOD (1000LL*1000*1000+7)
#define INF (MOD*MOD)
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define tri pair<ll,pll>
#define vpll vector<pll>
#define vvll vector<vll>
#define LL(t) ll t;cin>>t
#define VLL(v,n) vll v(n);f(i,0,n){cin>>v[i];}

ll power(ll a, ll b, ll mod) { // return (a^b)%mod
    if(b==0) return 1;
    ll half=power(a,b / 2,mod);
    ll full=(half*half)%mod;
    return (b%2) ? (a*full)%mod : full;
}

ll divMod(ll a, ll b, ll mod){ // return (a/b) % mod , works iff a%b=0
    return ((a%mod)*(power(b, MOD-2, MOD)))%mod;
}

bool comp(tri & a, tri &b){
    if(a.first!=b.first)
        return a.first < b.first;
    else{
        if(a.S.F!=b.S.F)
            return a.S.F < b.S.F;
        else
            return a.S.S < b.S.S;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    LL(q);
    while (q--){
        ll n,a,b;
        cin>>n>>a>>b;
//        n=5,a=(25-q-1)/5,b=(25-q-1)%5;
//        cout<<a<<" "<<b<<" ";
        ll num=min(min(a,b),min(n-1-a,n-1-b));
        ll ind=n*num*2+2*num*(n-2*num)-1;
        if(num==a){
            cout<<ind+b+1-num<<endl;
        }else{
            ind+=n-2*num;
            if(num==n-1-b){
                cout<<ind+a-num<<endl;
            }else{
                ind+=n-2*num-1;
                if(num==n-1-a){
                    cout<<ind+(n-1-num)-b<<endl;
                }else{
                    ind+=n-2*num-1;
                    cout<<ind+(n-1-num)-a<<endl;
                }
            }
        }
    }
    return 0;
}
0