Submission #2854158

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

void solve(int N,int x){
    int xmin = 1, xmax = 2*N-1;
    if (x <= xmin || xmax <= x) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    vi a(2*N-1, 0);
    if (N==2) {
        // x==2
        rep(i,3) a[i] = 1+i;
    } else {
        vector<bool> used(2*N, false);

        a[N] = x; used[x] = true;
        if (x <= N) {
            // ... x+1 1 x x+2 ...
            a[N-1] = 1;   used[1] = true;
            a[N-2] = x+1; used[x+1] = true;
            a[N+1] = x+2; used[x+2] = true;
        } else {
            // ... x-1 2n-1 x x-2 ...
            a[N-1] = 2*N-1; used[2*N-1] = true;
            a[N-2] = x-1;   used[x-1] = true;
            a[N+1] = x-2;   used[x-2] = true;
        }
        for (int i=0,j=1; i<=2*N-1; ++i) {
            if (a[i] == 0) {
                while (used[j]) ++j;
                a[i] = j++;
            }
        }
    }

#ifdef DEBUG
    fprintf(stderr, "N=%d, x=%d\n", N, x);
    cerr << a << endl;
#endif
    rep(i, 2*N-1) {
        cout << a[i] << endl;
    }
}

int main() {
    int N,x; cin>>N>>x;
    solve(N,x);
    return 0;
}

Submission Info

Submission Time
Task B - Median Pyramid Easy
User naoya_t
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2441 Byte
Status
Exec Time 319 ms
Memory 2304 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt
All 400 / 400 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt
Case Name Status Exec Time Memory
0_00.txt 1 ms 256 KB
0_01.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 1 ms 256 KB
1_03.txt 1 ms 256 KB
1_04.txt 1 ms 256 KB
1_05.txt 1 ms 256 KB
1_06.txt 1 ms 256 KB
1_07.txt 1 ms 256 KB
1_08.txt 1 ms 256 KB
1_09.txt 319 ms 2304 KB
1_10.txt 310 ms 2304 KB
1_11.txt 306 ms 2304 KB
1_12.txt 304 ms 2304 KB
1_13.txt 311 ms 2304 KB
1_14.txt 1 ms 256 KB
1_15.txt 1 ms 256 KB
1_16.txt 189 ms 1408 KB
1_17.txt 300 ms 2304 KB
1_18.txt 131 ms 1024 KB
1_19.txt 1 ms 256 KB