結果
| 問題 | 
                            No.831 都市めぐり
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-05-25 16:53:30 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,196 bytes | 
| コンパイル時間 | 654 ms | 
| コンパイル使用メモリ | 75,808 KB | 
| 実行使用メモリ | 18,924 KB | 
| 最終ジャッジ日時 | 2024-09-17 15:05:23 | 
| 合計ジャッジ時間 | 1,364 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 18 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
  /*
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[i] = i + 1;
  }
  int ans = 1e9;
  do {
    int cost = 0;
    for (int i = 0; i < n; i++) {
      cost += p[i] * p[(i + 1) % n];
    }
    ans = min(ans, cost);
  } while (next_permutation(p.begin(), p.end()));
  do {
    int cost = 0;
    for (int i = 0; i < n; i++) {
      cost += p[i] * p[(i + 1) % n];
    }
    if (cost == ans) {
      for (int i = 0; i < n; i++) {
        cout << p[i] << ' ';
      }
      cout << '\n';
    }
  } while (next_permutation(p.begin(), p.end()));
  1 9 3 7 5 6 4 8 2 10
  */
  int n;
  cin >> n;
  vector<int> L, R;
  int l = 1, r = n;
  for (int i = 1; i <= n; i++) {
    switch ((i - 1) % 4) {
      case 0: L.push_back(l++); break;
      case 1: R.push_back(r--); break;
      case 2: R.push_back(l++); break;
      case 3: L.push_back(r--); break;
    }
  }
  reverse(R.begin(), R.end());
  L.insert(L.end(), R.begin(), R.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (long long)L[i] * L[(i + 1) % n];
  }
  cout << ans << '\n';
}