Submission #1202095

#TimeUsernameProblemLanguageResultExecution timeMemory
1202095ericl23302Unscrambling a Messy Bug (IOI16_messy)C++20
38 / 100
0 ms328 KiB
#include <vector>
#include <iostream>
#include <string>

#include "messy.h"

using namespace std;

std::vector<int> restore_permutation(int n, int w, int r) { 
    vector<int> mapTo(n, -1);
    vector<bool> used(n, false);
    string str = "";
    for (int i = 0; i < n; ++i) str += "0";
    for (int i = 0; i < n - 1; ++i) {
        str[i] = '1';
        add_element(str);
    };

    compile_set();

    for (int i = 0; i < n; ++i) {
        str = "";
        for (int i = 0; i < n; ++i) str += "0";
        for (int j = 0; j < i; ++j) str[mapTo[j]] = '1';
        for (int j = 0; j < n; ++j) {
            if (str[j] == '1') continue;
            str[j] = '1';
            if (check_element(str)) {
                mapTo[i] = j;
                used[j] = true;
                break;
            }
            str[j] = '0';
        }
    }

    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            mapTo[n - 1] = i;
            break;
        }
    }

    vector<int> res(n, -1);
    for (int i = 0; i < n; ++i) res[mapTo[i]] = i;

    return res;
}

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...