Submission #1245017

#TimeUsernameProblemLanguageResultExecution timeMemory
1245017chinesegenius69420Unscrambling a Messy Bug (IOI16_messy)C++20
38 / 100
1 ms328 KiB
#include <bits/stdc++.h>
#include "messy.h"
#define dbg(x) cerr << #x << ": " << x << "\n";
using namespace std;

vector<int> restore_permutation(int n, int w, int r) {
    for(int i = 1; i < n; i++){
        string aux = "";
        for(int j = 0; j < i; j++){
            aux += '1';
        }
        for(int j = i + 1; j <= n; j++){
            aux += '0';
        }
        add_element(aux);
    }
    compile_set();
    vector<int> pos;
    while(pos.size() != n - 1){
        string aux(n, '0');
        for(const int &i : pos){
            aux[i] = '1';
        }
        int actpos = 0;
        while(actpos < n and aux[actpos] == '1') actpos++;
        while(1){
            aux[actpos] = '1';
            if(check_element(aux)){
                break;
            }
            aux[actpos] = '0';
            actpos++;
            while(actpos < n and aux[actpos] == '1') actpos++;
        }
        pos.push_back(actpos);
    }
    int x = 0, y = n * (n - 1) / 2;
    for(const int &i : pos) x += i;
    pos.push_back(y - x);
    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        ans[pos[i]] = i;
    }
    return ans;
}

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