結果
| 問題 |
No.831 都市めぐり
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-24 17:18:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 830 bytes |
| コンパイル時間 | 1,883 ms |
| コンパイル使用メモリ | 171,084 KB |
| 実行使用メモリ | 34,664 KB |
| 最終ジャッジ日時 | 2024-09-17 10:10:01 |
| 合計ジャッジ時間 | 2,756 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
ll N;
cin >> N;
if (N == 1) {
cout << 0 << endl;
return 0;
}
ll num = 1;
vector<ll> A, B;
for (ll i = 0; i < N; i++) {
if (i % 2 == 0) {
if (i % 4 == 0) {
A.push_back(num);
} else {
B.push_back(num);
}
num = N - num + 1;
} else {
if (i % 4 == 1) {
B.push_back(num);
} else {
A.push_back(num);
}
num = N - num + 2;
}
}
reverse(B.begin(), B.end());
A.insert(A.end(), B.begin(), B.end());
ll res = 0;
for (ll i = 0; i < N; i++) {
res += A[i] * A[(i + 1) % N];
}
cout << res << endl;
}