結果

問題 No.831 都市めぐり
ユーザー ttttan2ttttan2
提出日時 2019-05-24 21:57:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,369 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 164,100 KB
実行使用メモリ 18,024 KB
最終ジャッジ日時 2023-10-17 12:32:18
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 5 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 409 ms
5,556 KB
testcase_13 AC 286 ms
5,292 KB
testcase_14 AC 406 ms
5,556 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
    
    }
    vector<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.insert(ans.begin(),v[nv]);
            nv--;
        }
        if(i%4==1){
            
            ans.push_back(v[nv]);
            nv=(i-1)/2;
        }
        if(i%4==2){
            
            ans.insert(ans.begin(),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