Submission #764682

# Submission time Handle Problem Language Result Execution time Memory
764682 2023-06-23T21:04:19 Z raysh07 Unscrambling a Messy Bug (IOI16_messy) C++17
20 / 100
1 ms 340 KB
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> restore_permutation(int n, int w, int r) {
    // add_element("0");
    // compile_set();
    // check_element("0");
    // return std::vector<int>();
    
    for (int i = 0; i < n; i++){
        string s = "";
        for (int j = 0; j < n; j++){
            if (j <= i) s += "1";
            else s += "0";
        }
        
        add_element(s);
    }
    
    compile_set();
    vector <int> curr;
    for (int i = 0; i < n; i++) curr.push_back(i);
    
    vector <int> p(n);
    string s;
    for (int i = 0; i < n; i++) s += "0";
    int id = 0;
    
    while (curr.size()){
        random_shuffle(curr.begin(), curr.end());
        int got = -1;
        
        for (auto x : curr){
            if (x == curr.back()){
                got = x; break;
            }
            string str = s;
            str[x] = '1';
            
            if (check_element(str)){
                got = x;
                break;
            }
        } 
        
        assert(got != -1);
        vector <int> nc;
        for (auto x : curr){
            if (x != got) nc.push_back(x);
        }
        
        curr = nc;
        s[got] = '1';
        p[id++] = got; 
    }
    
    return p;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 8
2 Correct 0 ms 212 KB n = 8
3 Correct 0 ms 212 KB n = 8
4 Correct 0 ms 212 KB n = 8
5 Correct 0 ms 212 KB n = 8
6 Correct 0 ms 212 KB n = 8
7 Correct 0 ms 212 KB n = 8
8 Correct 0 ms 212 KB n = 8
9 Correct 0 ms 212 KB n = 8
10 Correct 1 ms 212 KB n = 8
11 Correct 1 ms 212 KB n = 8
12 Correct 0 ms 212 KB n = 8
13 Correct 0 ms 212 KB n = 8
14 Correct 0 ms 212 KB n = 8
15 Correct 1 ms 212 KB n = 8
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 32
2 Correct 1 ms 212 KB n = 32
3 Correct 0 ms 212 KB n = 32
4 Incorrect 0 ms 212 KB grader returned WA
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB grader returned WA
2 Halted 0 ms 0 KB -