제출 #1021135

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

using namespace std;

vector<int> restore_permutation(int n, int w, int r) {

    string s1 = "10101010", s2 = "11001100";
    add_element(s1);
    add_element(s2);

    compile_set();

    vector<int> perm(n);
    for (int i = 0; i < n; i++) {
        perm[i] = i;
    }

    bool isS1 = check_element(s1), isS2 = check_element(s2);
    if (isS1 && isS2) return perm;

    if (!isS1) { // swap happened between 1 and 0
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (s1[i] == s1[j]) continue;
                swap(s1[i], s1[j]);
                if (check_element(s1)) {
                    swap(perm[i], perm[j]);
                    return perm;
                }
                swap(s1[i], s1[j]);
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (s2[i] == s2[j]) continue;
                swap(s2[i], s2[j]);
                if (check_element(s2)) {
                    swap(perm[i], perm[j]);
                    return perm;
                }
                swap(s2[i], s2[j]);
            }
        }
    }
    return perm;
}
#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...