結果
| 問題 | 
                            No.1743 Permutation Code
                             | 
                    
| ユーザー | 
                             FplusFplusF
                         | 
                    
| 提出日時 | 2022-12-01 00:59:08 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,079 bytes | 
| コンパイル時間 | 2,552 ms | 
| コンパイル使用メモリ | 207,972 KB | 
| 最終ジャッジ日時 | 2025-02-09 02:57:53 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 1 WA * 22 TLE * 7 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
string ten_to_two(int x){
    string s;
    while(0<x){
        s.push_back(x%2+'0');
        x/=2;
    }
    reverse(all(s));
    return s;
}
int main(){
    string c;
    cin >> c;
    int k=c.size();
    int n=0,sum=0;
    while(sum<k){
        sum+=ten_to_two(n).size();
        n++;
    }
    n--;
    vector<string> s(n+1);
    for(int i=1;i<=n;i++){
        s[i]=ten_to_two(i);
    }
    vector<pair<int,int>> ans;
    vector<bool> used(k,false);
    for(int i=n;1<=i;i--){
        int z=s[i].size();
        if(i%2==0){
            rep(j,k-z+1){
                bool t=true;
                for(int ii=j;ii<j+z;ii++){
                    if(used[ii]){
                        t=false;
                        break;
                    }
                }
                if(!t) continue;
                if(s[i]==c.substr(j,z)){
                    if(j+z<k&&c[j+z]=='0') continue;
                    for(int ii=j;ii<j+z;ii++) used[ii]=true;
                    ans.push_back({j,i});
                    break;
                }
            }
        }else{
            for(int j=k-z+1;0<=j;j--){
                bool t=true;
                for(int ii=j;ii<j+z;ii++){
                    if(used[ii]){
                        t=false;
                        break;
                    }
                }
                if(!t) continue;
                if(s[i]==c.substr(j,z)){
                    if(j+z<k&&c[j+z]=='0') continue;
                    for(int ii=j;ii<j+z;ii++) used[ii]=true;
                    ans.push_back({j,i});
                    break;
                }
            }
        }
        
    }
    sort(all(ans));
    rep(i,n) cout << ans[i].second << " ";
    cout << endl;
}
            
            
            
        
            
FplusFplusF