#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
vector<int> restore_permutation(int n, int w, int r){
    //string Primero = "01010101", Segundo = "00110011", Tercero = "00001111";
    string c = "00000000";
    vector<int> Retorno(8);
    if(n == 8){
        Retorno[7] = 7;
        for(int i = 0; i < 7; i++){
            Retorno[i] = i;
            c[i] = '1';
            add_element(c);
        }
        compile_set();
        c = "00000000";
        int Primero = -2, Segundo = -2;
        for(int i = 0; i < 8; i++){
            c[i] = '1';
            bool Actual = check_element(c);
            if(Actual and Primero != -2){
                Segundo = i;
                swap(Retorno[Primero], Retorno[Segundo]);
                return Retorno;
            }
            if(Actual == 0 and Primero == -2) Primero = i;
        }
        if(Primero != -2){
            Segundo = 7;
            swap(Retorno[Primero], Retorno[Segundo]);
            return Retorno;
        }
        return Retorno;
        /*add_element(Primero);
        add_element(Segundo);
        add_element(Tercero);
        compile_set();
        if(check_element(Primero)){
            if(check_element(Segundo)){
                if(check_element(Tercero)){
                    for(int i = 0; i < 8; i++) Retorno[i] = i;
                    return Retorno;
                } else {
                    for(int i = 0; i < 8; i++){
                        for(int j = i + 1; j < 8; j++){
                            if(Tercero[i] == Tercero[j]) continue;
                            swap(Tercero[i], Tercero[j]);
                            if(check_element(Tercero)){
                                for(int k = 0; k < 8; k++){
                                    Retorno[k] = k;
                                    if(k == i) Retorno[k] = j;
                                    if(k == j) Retorno[k] = i;
                                }
                                return Retorno;
                            }
                            swap(Tercero[i], Tercero[j]);
                        }
                    }
                }
            } else {
                for(int i = 0; i < 8; i++){
                    for(int j = i + 1; j < 8; j++){
                        if(Segundo[i] == Segundo[j]) continue;
                        swap(Segundo[i], Segundo[j]);
                        if(check_element(Segundo)){
                            for(int k = 0; k < 8; k++){
                                Retorno[k] = k;
                                if(k == i) Retorno[k] = j;
                                if(k == j) Retorno[k] = i;
                            }
                            return Retorno;
                        }
                        swap(Segundo[i], Segundo[j]);
                    }
                }
            }
        } else {
            for(int i = 0; i < 8; i++){
                for(int j = i + 1; j < 8; j++){
                    if(Primero[i] == Primero[j]) continue;
                    swap(Primero[i], Primero[j]);
                    if(check_element(Primero)){
                        //cerr<<Primero<<"\n";
                        for(int k = 0; k < 8; k++){
                            Retorno[k] = k;
                            if(k == i) Retorno[k] = j;
                            if(k == j) Retorno[k] = i;
                        }
                        return Retorno;
                    }
                    swap(Primero[i], Primero[j]);
                }
            }
        }*/
    }
}
Compilation message (stderr)
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:96:1: warning: control reaches end of non-void function [-Wreturn-type]
   96 | }
      | ^
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 time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |