Submission #1233337

#TimeUsernameProblemLanguageResultExecution timeMemory
1233337kaltspielerhyUnscrambling a Messy Bug (IOI16_messy)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#include "messy.h"

vector<int> restore_permutation(int n, int w, int r) {
    string e1;
    string e2;
    string e3;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            e1.push_back('0');
        }
        else {
            e1.push_back('1');
        }

        if (i%4 == 0 || i%4 == 3 || i%4==2) {
            e2.push_back('1');
            e3.push_back('0');
        }
        else {
            e2.push_back('0');
            e3.push_back('1');
        }
    }

    add_element(e1);
    add_element(e2);
    compile_set();

    vector<int> permutation(n);
    for (int i = 0; i < n; i++) permutation[i] = i;
    bool finished = false;
    for (int d = 0; d < n; d++) {
        for (int f = d+1; f < n; f++) {
            swap(e1[d], e1[f]);
            swap(e2[d], e2[f]);
            swap(e3[d], e3[f]);

            if (check_element(e1) && check_element(e2) && check_element(e3)) {
                cerr << d << ' ' << f << '\n';
                if (finished) {
                    for (int i = 0; i < n; i++) permutation[i] = i;
                    swap(e1[d], e1[f]);
                    swap(e2[d], e2[f]);
                    swap(e3[d], e3[f]);
                    break;
                }
                swap(permutation[d], permutation[f]);
                finished = true;
                swap(e1[d], e1[f]);
                swap(e2[d], e2[f]);
            swap(e3[d], e3[f]);
                break;
            }

            swap(e1[d], e1[f]);
            swap(e2[d], e2[f]);
            swap(e3[d], e3[f]);
        }
    }

    return permutation;
}

Compilation message (stderr)

messy.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...