Submission #591445

# Submission time Handle Problem Language Result Execution time Memory
591445 2022-07-07T12:38:59 Z Vanilla Unscrambling a Messy Bug (IOI16_messy) C++17
20 / 100
1 ms 340 KB
#include <bits/stdc++.h>
#include "messy.h"
#include <vector>
using namespace std;

vector<int> restore_permutation(int n, int w, int r) {
    string s = "";
    for (int i = 0; i < n; i++){
        s.push_back('1');
    }
    for (int i = 0; i < n; i++){
        add_element(s);
        s[i] = '0';
    }
    compile_set();
    if (n == 8) {
        vector <int> frq (128);
        for (int i = 0; i < 256; i++){
            string s = "";
            for (int j = 0; j < 8; j++){
                s = char('0' + !!(i & (1 << j))) + s;
            }
            if(check_element(s)) {
                for (int j = 0; j < 8; j++){
                    if (s[j] == '1') frq[j]++;
                }
            }
        }
        vector <int> p (n);
        for (int i = 0; i < n; i++){
            p[i] = frq[i] - 1;
        }
        return p;
    }
    else if (n == 32) {
        s = "";
        for (int j = 0; j < n; j++) s.push_back('1');
        vector <int> p (32);
        vector <int> v;
        for (int j = 0; j < n; j++) v.push_back(j);
        for (int i = 0; i < n; i++){
            shuffle(v.begin(), v.end(), std::default_random_engine(chrono::system_clock::now().time_since_epoch().count()));
            for (int j: v){
                if (s[j] == '1') {
                    s[j] = '0';
                    if (check_element(s)) {
                        p[j] = i;
                        break;
                    }
                    s[j] = '1';
                }
            }
        }
        return p;
    }
    return vector <int> ();
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 212 KB n = 8
6 Correct 1 ms 212 KB n = 8
7 Correct 0 ms 212 KB n = 8
8 Correct 0 ms 212 KB n = 8
9 Correct 1 ms 212 KB n = 8
10 Correct 1 ms 212 KB n = 8
11 Correct 0 ms 212 KB n = 8
12 Correct 1 ms 212 KB n = 8
13 Correct 0 ms 212 KB n = 8
14 Correct 1 ms 212 KB n = 8
15 Correct 1 ms 212 KB n = 8
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB grader returned WA
2 Halted 0 ms 0 KB -
# 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 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 -