結果

問題 No.1743 Permutation Code
ユーザー ミドリムシミドリムシ
提出日時 2021-08-20 11:30:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,496 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 172,280 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2023-08-20 08:48:16
合計ジャッジ時間 12,916 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 5 ms
4,384 KB
testcase_06 AC 44 ms
4,380 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountll((lint)(n))
#define highest(x) (63 - __builtin_clzll(x))
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define rep2(i, l, r) for(int i = int(l); i < int(r); i++)
#define repr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define repr2(i, l, r) for(int i = int(r) - 1; i >= int(l); i--)
template<class itr> void array_output(itr start, itr goal){ for(auto i = start; i != goal; i++) cout << (i == start ? "" : " ") << (*i); cout << endl; }

string c;
int n;
int sub[1001001][20];

vector<bool> is_used;
vector<int> ans;

void dfs(int at){
    if(at == c.size()){
        array_output(all(ans));
        exit(0);
    }
    if(c[at] == '0') return;
    
    rep(i, 20){
        int num = sub[at][i];
        if(num == 0 || num > n || is_used[num]) continue;
        
        is_used[num] = true;
        ans.push_back(num);
        dfs(at + i + 1);
        is_used[num] = false;
        ans.pop_back();
    }
}

int main(){
    cin >> c;
    n = 0;
    int tmp = 0;
    while(tmp < c.size()){
        n++;
        tmp += highest(n) + 1;
    }
    
    rep(i, c.size()){
        int num = 0;
        rep(j, 20){
            if(i + j >= c.size()) continue;
            
            num = num * 2 + (c[i + j] - '0');
            sub[i][j] = num;
        }
    }
    
    is_used.assign(n + 1, false);
    dfs(0);
    abort();
}
0