結果

問題 No.294 SuperFizzBuzz
ユーザー outline
提出日時 2021-02-22 15:36:24
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,799 bytes
コンパイル時間 6,160 ms
コンパイル使用メモリ 188,896 KB
最終ジャッジ日時 2025-01-19 03:29:49
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 MLE * 1
other AC * 5 WA * 3 MLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    auto check = [](const string& s, const string& t){
        if(s.length() != t.length())    return s.length() < t.length();
        return s < t;
    };
    priority_queue<string, vector<string>, decltype(check)> que(check);
    for(int i = 3; i <= 15; i += 3){
        for(int j = 0; i + j <= 25; ++j){
            vector<int> perm(i + j - 1, 1);
            for(int k = 0; k < j; ++k)  perm[k] = 0;
            do {
                string s = "";
                for(int k = 0; k < i + j - 1; ++k){
                    s += perm[k] == 0 ? '3' : '5';
                }
                s += '5';
                que.emplace(s);
                if(que.size() > N)  que.pop();
            } while(next_permutation(begin(perm), end(perm)));
        }
    }

    cout << que.top() << endl;

    return 0;
}
0