Submission #1247728

#TimeUsernameProblemLanguageResultExecution timeMemory
1247728m_bezrutchkaUnscrambling a Messy Bug (IOI16_messy)C++20
38 / 100
1 ms328 KiB
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> restore_permutation(int n, int w, int r) {
    string s = "";
    for (int i = 0; i < n; i++) {
        s.push_back('0');
    }
    for (int i = 0; i < n; i++) {
        s[i] = '1';
        add_element(s);
    }

    compile_set();

    for (int i = 0; i < n; i++) {
        s[i] = '0';
    }
    vector<int> p(n);
    
    for (int i = 0; i < n; i++) {
        vector<int> to_test;
        for (int j = 0; j < n; j++) {
            if (s[j] == '1') continue;
            to_test.push_back(j);
        }
        shuffle(to_test.begin(), to_test.end(), rng);
        for (int j: to_test) {
            s[j] = '1';
            bool found = check_element(s);
            if (found) {
                p[j] = i;
                break;
            }
            s[j] = '0';
        }
    }
    return p;
}




Compilation message (stderr)

messy.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...