結果

問題 No.3267 PQ Straight
ユーザー Rumain831
提出日時 2025-09-12 23:44:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 536 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 78,284 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-12 23:47:41
合計ジャッジ時間 3,477 ms
ジャッジサーバーID
(参考情報)
judge2 / judge10
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:11: warning: ‘last’ may be used uninitialized [-Wmaybe-uninitialized]
   17 |   for(int i=last+2; i<n; i++) p[i]=p[i-1]+2;
      |           ^
main.cpp:14:7: note: ‘last’ was declared here
   14 |   int last, st=(n+3)/2;
      |       ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
  int n; cin >> n;
  if(n%2==0){
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;
  vector<int> p(n), q(n);
  int last, st=(n+3)/2;
  for(int i=0; i<n/2+1; i++) p[i]=2*i+1, last=i;
  p[last+1]=2;
  for(int i=last+2; i<n; i++) p[i]=p[i-1]+2;
  for(int i=0; i<n; i++){
    q[i]=st+i-p[i];
  }
  for(auto pp:p) cout << pp << ' '; cout << endl;
  for(auto pp:q) cout << pp << ' '; cout << endl;
  return 0;
}
0