結果
| 問題 |
No.696 square1001 and Permutation 5
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2018-06-09 11:23:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 707 bytes |
| コンパイル時間 | 4,057 ms |
| コンパイル使用メモリ | 289,560 KB |
| 実行使用メモリ | 25,428 KB |
| 最終ジャッジ日時 | 2024-06-30 12:29:30 |
| 合計ジャッジ時間 | 26,623 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 11 |
ソースコード
#include <vector>
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
int main() {
using boost::multiprecision::cpp_int;
cin.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> p(n), bit(n);
vector<cpp_int> a(n), b(n);
for (int i = 0; i < n; i++) cin >> p[i];
for (int i = n - 1; i >= 0; i--) {
int x = 0;
for (int j = p[i] - 1; j >= 1; j -= j & (-j)) x += bit[j];
for (int j = p[i]; j < n; j += j & (-j)) bit[j]++;
a[n - i - 1] = x;
b[i] = i + 1;
}
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j + i < n; j += 2 * i) {
a[j] = a[j] + b[j] * a[j + i];
b[j] = b[j] * b[j + i];
}
}
cout << a[0] + 1 << endl;
return 0;
}
square1001