結果
問題 |
No.3267 PQ Straight
|
ユーザー |
![]() |
提出日時 | 2025-09-16 18:17:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 1,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 3,008 ms |
コンパイル使用メモリ | 278,164 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-16 18:17:51 |
合計ジャッジ時間 | 6,080 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/modint> using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); /* 初項をaとすると aN + N(N-1)/2 = N(N+1) 2a = N+3 だからまずNが奇数でないと不可能。 奇数のときこんな感じで構築できる。 P, 1 4 2 5 3 Q, 3 1 4 2 5 S, 4 5 6 7 8 */ int N; cin >> N; if (N % 2 == 0){ cout << "No" << endl; return 0; } int a = (N+3)/2; vector<int> P(N), Q(N); P[0] = 1; Q[0] = a-1; for (int i=1; i<N; i++){ P[i] = Q[i-1]+1; Q[i] = P[i-1]; } cout << "Yes" << endl; for (int i=0; i<N; i++) cout << P[i] << " "; cout << endl; for (int i=0; i<N; i++) cout << Q[i] << " "; cout << endl; return 0; }