Submission #1121801

#TimeUsernameProblemLanguageResultExecution timeMemory
1121801OmarAlimammadzadeUnscrambling a Messy Bug (IOI16_messy)C++14
20 / 100
2 ms504 KiB
// author - alimammadzade

#include "messy.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> restore_permutation(int n, int w, int r) {
    vector<string> nums;
    vector<int> res(n);
    int query = 0;
    iota(res.begin(), res.end(), 0);
    string s = "";
    for (int i = 0; i < n; i++) {
        s += "1";
        string q;
        for (int j = 0; j < n - i - 1; j++) q += "0";
        q += s;
        add_element(q);
        nums.push_back(q);
    }
    compile_set();
    for (int i = 0; i < n; i++)
        for (int j = n - 1; j >= n - i - 1; j--)
            for (int k = 0; k < n - i - 1; k++) {
                string a = nums[i];
                swap(a[j], a[k]);
                if (check_element(a)) {
                    swap(res[j], res[k]);
                    return res;
                }
            }
    return res;
}

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:10:9: warning: unused variable 'query' [-Wunused-variable]
   10 |     int query = 0;
      |         ^~~~~
#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...