結果
| 問題 |
No.3271 PQ Dot Product
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-23 21:55:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,480 bytes |
| コンパイル時間 | 2,849 ms |
| コンパイル使用メモリ | 283,984 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-09-23 21:55:42 |
| 合計ジャッジ時間 | 13,222 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 25 |
ソースコード
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
using std::cin, std::cout, std::cerr;
using ll = long long;
int main() {
std::ios::sync_with_stdio(false);
ll n; ll m; cin >> n >> m;
std::vector<int> q;
ll orig_n = n;
int shift = 0;
while(n > 10) {
n --;
ll min = ll(n) * (n + 1) * (n + 2) / 6;
ll max = ll(n) * (n + 1) * (2 * n + 1) / 6;
ll x = ll(n) * (n + 1) / 2 + n + 1;
ll y = ll(n + 1) * (n + 1);
// cout << n << ' ' << m << ' ' << min << ' ' << max << ' ' << x << ' ' << y << '\n';
if(max + x >= m) {
m -= x;
q.push_back(1);
shift ++;
} else {
m -= y;
q.push_back(n + 1 + shift);
}
}
bool done = false;
std::vector<int> p(n);
std::iota(p.begin(), p.end(), 1);
do {
int ans = 0;
for(int i = 0; i < n; i ++) {
ans += (i + 1) * p[i];
}
if(ans == m) {
done = true;
break;
}
}while(std::next_permutation(p.begin(), p.end()));
if(!done) {
cout << "No\n";
} else {
cout << "Yes\n";
for(int &x : p) x += shift;
p.insert(p.end(), q.rbegin(), q.rend());
for(int i = 1; i <= orig_n; i ++) cout << i << ' '; cout << '\n';
for(int x : p) cout << x << ' '; cout << '\n';
}
}