제출 #1214453

#제출 시각아이디문제언어결과실행 시간메모리
1214453aykhnNewspapers (CEOI21_newspapers)C++20
8 / 100
0 ms328 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define inf 0x3F3F3F3F3F3F3F3F

const int MXN = 1e6 + 5;
const int LOG = 20;

signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (n == 1)
  {
    cout << "YES\n1\n1\n";
    return 0;
  }
  if (n == 2)
  {
    cout << "YES\n2\n1 1\n";
    return 0;
  }
  cout << "YES\n" << 2 * (n - 2) << '\n';
  if (!(n & 1))
  {
    for (int i = 2; i <= n - 1; i++) cout << i << ' ';
    for (int i = n - 1; i >= 2; i--) cout << i << ' ';
    cout << '\n';
  }
  else
  {
    for (int i = 2; i <= n - 1; i++) cout << i << ' ';
    for (int i = 2; i <= n - 1; i++) cout << i << ' ';
    cout << '\n';
  }
  return 0;
  // int d[(1 << n)];
  // array<int, 2> par[(1 << n)];
  // fill(d, d + (1 << n), inf);
  // queue<int> q;
  // d[(1 << n) - 1] = 0;
  // q.push((1 << n) - 1);
  // while (!q.empty())
  // {
  //   int msk = q.front();
  //   q.pop();
  //   for (int i = 0; i < n; i++)
  //   {
  //     int upd = (msk | (1 << i)) ^ (1 << i), nw = 0;
  //     for (int j = 0; j < n; j++)
  //     {
  //       if (j) nw |= (upd >> (j - 1) & 1) << j;
  //       if (j + 1 < n) nw |= (upd >> (j + 1) & 1) << j;
  //     }
  //     if (d[nw] > d[msk] + 1) 
  //     {
  //       d[nw] = d[msk] + 1;
  //       par[nw] = {msk, i};
  //       q.push(nw);
  //     }
  //   }
  // }
  // int cur = 0;
  // vector<int> res, st;
  // while (cur != (1 << n) - 1)
  // {
  //   st.push_back(cur);
  //   res.push_back(par[cur][1]);
  //   cur = par[cur][0];
  // }
  // reverse(res.begin(), res.end());
  // reverse(st.begin(), st.end());
  // cout << d[0] << '\n';
  // for (int &i : res) cout << i + 1 << ' ';
  // cout << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...