제출 #1018696

#제출 시각아이디문제언어결과실행 시간메모리
1018696ProtonDecay314Unscrambling a Messy Bug (IOI16_messy)C++17
38 / 100
1 ms608 KiB
// AM+DG

/*

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
#define L(i, varmn, varmx) for(ll i = varmn; i < varmx; i++)
#define LR(i, varmx, varmn) for(ll i = varmx; i > varmn; i--)
#define LI(i, varmn, varmx) for(int i = varmn; i < varmx; i++)
#define LIR(i, varmx, varmn) for(int i = varmx; i > varmn; i--)
#define pb push_back
#include "messy.h"

// #define DEBUG

string to_binstring(int num, int n) {
    string res;

    LIR(i, n - 1, -1) {
        res.pb(((num >> i) & 0b1 ? '1' : '0'));
    }

    assert((int)res.size() == n);

    return res;
}

vi restore_permutation(int n, int w, int r) {
    LI(i, 0, n + 1) {
        // Construct a string with this many zeros
        string elem;
        LI(j, 0, i) {
            elem.pb('1');
        }

        LI(j, i, n) {
            elem.pb('0');
        }

        assert((int)elem.size() == n);
        add_element(elem);
    }


    compile_set();

    int cur_mask = 0;

    vi ans(n, 0);

    LI(i, 0, n) {
        LI(j, 0, n) {
            if(((cur_mask >> j) & 0b1) == 0) {
                if(check_element(to_binstring(cur_mask | (1 << j), n))) {
                    // We found the next bitpos
                    cur_mask |= (1 << j);

                    ans[n - j - 1] = i;
                    break;
                }
            }
        }
    }

    return ans;
}

#ifdef DEBUG
int main() {

}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...