結果

問題 No.831 都市めぐり
ユーザー ttttan2ttttan2
提出日時 2019-05-24 21:59:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,352 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 166,660 KB
実行使用メモリ 35,172 KB
最終ジャッジ日時 2023-10-17 12:33:11
合計ジャッジ時間 2,494 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 5 ms
4,768 KB
testcase_13 AC 4 ms
4,504 KB
testcase_14 AC 5 ms
4,768 KB
testcase_15 AC 23 ms
16,688 KB
testcase_16 AC 11 ms
8,896 KB
testcase_17 AC 27 ms
19,328 KB
testcase_18 AC 38 ms
24,220 KB
testcase_19 AC 49 ms
34,116 KB
testcase_20 AC 51 ms
35,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll n;cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    
    }
    deque<ll> ans;
    ans.push_back(1);
    vector<ll> v,w;
    rep(i,2,n+1)v.push_back(i);
    //cout<<v[0]<<w[0]<<endl;
    ll nv=n-2;
    rep(i,0,n-1){
        if(i%4==0){
            
            ans.push_front(v[nv]);
            nv--;
        }
        if(i%4==1){
            
            ans.push_back(v[nv]);
            nv=(i-1)/2;
        }
        if(i%4==2){
            
            ans.push_front(v[nv]);
            nv++;
        }
        if(i%4==3){
            
            ans.push_back(v[nv]);
            nv=n-2-(i+1)/2;
        }
       // cout<<nv<<endl;
    }
    ll sum=0;
    //rep(i,0,n)cout<<ans[i]<<" ";
    rep(i,0,n-1)sum+=ans[i]*ans[i+1]+ans[i+1]-ans[i];
    sum+=ans[0]*ans[n-1]+ans[0]-ans[n-1];
    cout<<sum<<endl;
}
0