結果

問題 No.831 都市めぐり
ユーザー tomarint2tomarint2
提出日時 2019-05-24 22:30:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,333 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 87,720 KB
実行使用メモリ 19,824 KB
最終ジャッジ日時 2023-10-17 12:55:35
合計ジャッジ時間 1,577 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,536 KB
testcase_13 AC 3 ms
4,400 KB
testcase_14 AC 2 ms
4,536 KB
testcase_15 WA -
testcase_16 AC 5 ms
6,564 KB
testcase_17 AC 11 ms
11,768 KB
testcase_18 WA -
testcase_19 AC 20 ms
19,252 KB
testcase_20 AC 20 ms
19,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <unordered_map>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll N;
    cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return;
    }
    deque<ll> q;
    q.push_back(1);
    ll s = 2;
    ll l = N;
    ll ans = 0;
    while(s < l) {
        q.push_front(l);
        --l;
        if (s > l) break;
        q.push_back(l);
        --l;
        if (s > l) break;
        q.push_front(s);
        ++s;
        if (s > l) break;
        q.push_back(s);
        ++s;
        if (s > l) break;
    }

    ll pre = q.back();
    //dumplist(q);
    for (ll a : q) {
        if (pre == 0) {
            pre = a;
        }
        else {
            ans += (pre * a) + (a - pre);
            pre = a;
        }
    }
    cout << ans << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}
0