제출 #1121855

#제출 시각아이디문제언어결과실행 시간메모리
1121855huseynahmadli2010Unscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h>

#include "messy.h"

using namespace std;

vector<int> restore_permutation(int n, int w, int r) {
    add_element("00000001");
    add_element("00000011");
    add_element("00000111");
    add_element("00001111");
    add_element("00011111");
    add_element("00111111");
    add_element("01111111");
    
    compile_set();
    
    vector<int> res={0,1,2,3,4,5,6,7};
    
    bool ans1=check_element("00000001");
    bool ans2=check_element("00000011");
    bool ans3=check_element("00000111");
    bool ans4=check_element("00001111");
    bool ans5=check_element("00011111");
    bool ans6=check_element("00111111");
    bool ans7=check_element("01111111");
    
    if(ans1)
    {
        if(ans2)
        {
            if(ans3)
            {
                if(ans4)
                {
                    if(ans5)
                    {
                        if(ans6)
                        {
                            if(ans7)
                                return res;
                            
                            else
                            {
                                string s="01111111";
                                
                                for(int i=1;i<8;i++)
                                {
                                    swap(s[i],s[0]);
                                    
                                    if(check_element(s))
                                    {
                                        swap(res[i],res[0]);
                                        
                                        return res;
                                    }
                                    
                                    swap(s[i],s[0]);
                                }
                            }
                        }
                        
                        else
                        {
                            string s="00111111";
                            
                            for(int j=0;j<2;j++)
                            {
                                for(int i=2;i<8;i++)
                                {
                                    swap(s[i],s[j]);
                                    
                                    if(check_element(s))
                                    {
                                        swap(res[i],res[j]);
                                        
                                        return res;
                                    }
                                    
                                    swap(s[i],s[j]);
                                }
                            }
                        }
                    }
                    
                    else
                    {
                        string s="00011111";
                        
                        for(int j=0;j<3;j++)
                        {
                            for(int i=3;i<8;i++)
                            {
                                swap(s[i],s[j]);
                                
                                if(check_element(s))
                                {
                                    swap(res[i],res[j]);
                                    
                                    return res;
                                }
                                
                                swap(s[i],s[j]);
                            }
                        }
                    }
                }
                
                else
                {
                    string s="00001111";
                        
                    for(int j=0;j<4;j++)
                    {
                        for(int i=4;i<8;i++)
                        {
                            swap(s[i],s[j]);
                            
                            if(check_element(s))
                            {
                                swap(res[i],res[j]);
                                
                                return res;
                            }
                            
                            swap(s[i],s[j]);
                        }
                    }
                }
            }
            
            else
            {
                string s="00000111";
                        
                for(int j=0;j<5;j++)
                {
                    for(int i=5;i<8;i++)
                    {
                        swap(s[i],s[j]);
                        
                        if(check_element(s))
                        {
                            swap(res[i],res[j]);
                            
                            return res;
                        }
                        
                        swap(s[i],s[j]);
                    }
                }
            }
        }
        
        else
        {
            string s="000000011";
                        
            for(int j=0;j<6;j++)
            {
                for(int i=6;i<8;i++)
                {
                    swap(s[i],s[j]);
                    
                    if(check_element(s))
                    {
                        swap(res[i],res[j]);
                        
                        return res;
                    }
                    
                    swap(s[i],s[j]);
                }
            }
        }
    }
    
    else
    {
        string s="000000001";
                        
        for(int j=0;j<7;j++)
        {
            for(int i=7;i<8;i++)
            {
                swap(s[i],s[j]);
                
                if(check_element(s))
                {
                    swap(res[i],res[j]);
                    
                    return res;
                }
                
                swap(s[i],s[j]);
            }
        }
    }
  
    return res;
}
#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...