結果

問題 No.2671 NUPC Decompressor
ユーザー Astral__Astral__
提出日時 2024-03-15 21:29:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 7,477 bytes
コンパイル時間 3,368 ms
コンパイル使用メモリ 263,172 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-15 21:29:09
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//using uLL = unsigned __int128;
template <typename T> 
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using pq = priority_queue<T>;
using pll = pair<long long, long long>;
using pii = pair<int, int>;
using vvvvl = vector<vector<vector<vector<ll>>>>;
using vvvi = vector<vector<vector<int>>>;
using vvvl = vector<vector<vector<ll>>>;
using vvvc = vector<vector<vector<char>>>;
using vvvd = vector<vector<vector<double>>>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<pair<ll, ll>>>;
using vvb = vector<vector<bool>>;
using vvd = vector<vector<double>>;
using vp = vector<pair<ll, ll>>;
using vi = vector<int>;
using vl = vector<ll>;
using vu = vector<unsigned long long>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
#define vvvm  vector<vector<vector<mint>>>
#define vvm  vector<vector<mint>>
#define vm  vector<mint>
template <typename T1, typename T2>
using umap = unordered_map<T1, T2>;
template <typename T1, typename T2>
using uset = unordered_set<T1, T2>;
#define rrr(l, r) mt()%(r-l+1)+l
#define rep(i, s, f) for(long long i = s; i <= f; i++)
#define rep1(i, s, f) for(long long i = s; i <= f; i++)
#define per(i, s, f) for(long long i = s; i >= f; i--)
#define per1(i, s, f) for(long long i = s; i >= f; i--)
#define all0(x) (x).begin() ,(x).end()
#define all(x) (x).begin() + 1, (x).end()
#define ENDL '\n'
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//これが本当の組み込み関数ってね(笑)
template <typename T>
int LB(vector<T> &A, T x) {
    return lower_bound(A.begin(), A.end(), x) - A.begin();
}

template <typename T>
int UB(vector<T> &A, T x) {
    return upper_bound(A.begin(), A.end(), x) - A.begin();
}
template <typename T>
void UNIQUE(vector<T> &A, int indexed) {
    sort(A.begin() + indexed, A.end());
    A.erase(unique(A.begin() + indexed, A.end()), A.end());
}
int msb(long long a) {
    if(a == 0) return -1;
    return 64 - int(__builtin_clzll(a));
}
template<typename T = long long>
void chmin(T &a, T b) {
    a = min(a, b);
}
template<typename T = long long>
void chmax(T &a, T b) {
    a = max(a, b);
}
//////////////////////////////////////////////////////////////////////
//数学系
///////////////////////////////////////////////////////////////////////
ll extgcd (ll a, ll b,  ll &x, ll &y) {
    if(b == 0) { x = 1;y = 0;return a;}
    ll d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
template <typename T>
T ceil__(T a, T b) {
    assert(b != 0);
    if(a % b == 0) return a / b;
    if((a <= 0 && b < 0) || (a >= 0 && b > 0)) return a/b + 1;
    else return a / b;
}
template <typename T>
T floor__(T a, T b) {
    assert(b != 0);
    if(a % b == 0) return a / b;
    if((a <= 0 && b < 0) || (a >= 0 && b > 0)) return a/b;
    else return a/b - 1;
}
ll modpow(ll x, ll y, ll mod) {
    if(x > mod) x %= mod;
    if(y == 0) return 1;
    ll res = modpow(x, y >> 1, mod);
    res = res * res % mod;
    if(y & 1) res *= x, res %= mod;
    return res;
}
ll sqrt__(ll a) {
    ll l = 0;
    ll r = 3037000499LL;
    while(l < r) {
        ll mid = (l + r + 1) / 2;
        if(mid * mid <= a) l = mid;
        else r = mid - 1;
    }
    return l;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//グローバル変数を置くところ
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize "trapv" //お祈り。変数同士の演算でのみ感知。代入や、 a *= 10000 では感知しない。
const ll big = 1001001001;
const ll BIG = 1001001001001001001LL;
const double pi = 3.141592653589793;
vl dx{0, 1, 0, -1, 0, 1, 1, -1, -1};  // 座標平面において、(番兵) → ↓ ← ↑  ※ 右から時計回り 注 : グリッド or 座標で上下は反転する。
vl dy{0, 0, -1, 0, 1, 1, -1, -1, 1};
//const ll mod = 1000000007;
//const ll mod = 998244353;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void solve() {
    int K;
    cin >> K;

   vector<char> al{'N', 'U', 'P', 'C'};
    vector<string> A;
    auto dfs = [&](auto f, string now, int d) -> void {
        if(d==4) {
            A.push_back(now);return;
        }
        else {
            now += al[d];
            f(f, now, d+1);
            now += now;
            f(f, now, d+1);


        }

    };

    string n = "";
    dfs(dfs, n, 0);

    sort(all0(A));
    cout << A[K-1] << endl;



    
    

}



/*

-違法な読み替えをしていないか・違法な操作をしていないか
・実装が重そうな時は確認する 一度飛ばしても良い
・waが出た時は嘘を吐いていないかの他に、違法な操作をしていないかもチェックする
特にふわっとした操作は危ない
・区間をちょっと伸ばす←伸ばす余地はあるか
・選択肢のうち、どれでも良いから消す←本当にどれでも良いか 場合分けを挟んでないか

-その情報はdpで纏めて良いものか
・dpで持つ:「この先の探索をするのに必要な情報」 なぜ必要なのか?
・途中までは辻褄が合っても、最後に分岐とかはある

-何もわからないという時
・解を列挙した上で特徴づけ
・制約に具体的な数値が登場している←適当に解をいじると何となく性質が見えることが多い
・何もわからない(自由度が高い) という時
    -解の形を貪欲で絞る
    -上階が達成できガチ 必要条件をつみかさねていく ”非自明な最悪ケース(例:点の数が多いのに答え=0)”を作る時、何を意識したか?
・要素と制約をグラフで表してみる
・制約を「全ての要素についてoo ⇔ (1<=i<=N)で、iについてoo」といったように、独立なものに言い換えた方がやりやすいこともある
・よくわからないものを言い換える。
    -慣れ親しんだ制約も、問題設定によってより扱いやすい形に言い換えられるかもしれない(例:グラフが連結)

-一つの解法で駄目な時、周辺の解法も試すようにする。周辺で見えないなら全部試す。
・「貪欲で最適解」と「解の形を絞って全探索」
・「dp/最適化」と「解の形を絞って全探索」と 上界を見積もる」
・「dp」と「必要な情報を言い換える・何でのその情報が必要なのか考える事による高速化」
・「dp」と「探索の順番を変更する: でかい方から、深い方から、DAGで先端になっている・或いは葉になっている所から、全てを逆に言い換えて時系列的に後ろから」
・「dp」と「軸にするものを変える: マスを軸にするのではなく、燃料を軸にするなど」

*/

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(15);
    ll T = 1;
    //cin >> T;
    rep(i, 1, T) {
        solve();
    }
  return 0;
}
0