답안 #1094798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094798 2024-09-30T15:29:09 Z makrav "The Lyuboyn" code (IZhO19_lyuboyn) C++14
3 / 100
51 ms 7080 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second

int count(int x, int y) {
    return __builtin_popcount((x ^ y));
}

string int2s(int x, int siz) {
    string rs;
    while (x) {
        rs += char('0' + (x & 1));
        x >>= 1;
    }
    while (sz(rs) < siz) rs += '0';
    return rs;
}

void solve() {
    int n, k, t; cin >> n >> k >> t;
    string S; cin >> S;
    if (k % 2 == 0) {
        cout << "-1\n";
        return;
    }

    auto solve2 = [&](int N, auto&&self) -> vector<int> {
        if (N == 2) return {3};
        if (N == 3) return {6, 3, 6};

        auto ans = self(N - 2, self);
        int X = 0;
        for (int i = 0; i < sz(ans); i++) X = (X ^ ans[i]);
        int start2 = 0;
        for (int val = 0; val < (1 << (N - 2)); val++) {
            if (count(0, val) == 1 && count(X, val) == 1) start2 = val;
        }
        assert(start2);
        vector<int> newans;
        vector<int> lol = {0, 2, 3, 1};
        for (int i = 0; i < 4; i++) {
            for (int u : ans) newans.pb(u);
            if (i < 3) {
                newans.pb((start2^X)+(lol[i+1]^lol[i])*(1<<(N-2)));
            }
        }
        return newans;
    };
    vector<int> rs = solve2(n, solve2);
    rs.pb(123);
    vector<int> ans;
    for (int i = 0; i < (1 << n); i++) {
        if (count(i, 0) == k && count(i, rs[0]) == k) {
            int cur1 = 0, cur2 = i;
            for (int j = 0; j < (1 << n); j++) {
                if (j % 2 == 0) {
                    ans.pb(cur1);
                    cur1 ^= rs[j >> 1];
                } else {
                    ans.pb(cur2);
                    cur2 ^= rs[j >> 1];
                }
            }
            break;
        }
    }
    cout << sz(ans) << '\n';
    for (int i = 0; i < sz(ans); i++) {
        if (int2s(ans[i], n) == S) {
            int cur = i, cnt = sz(ans);
            while (cnt) {
                cout << int2s(ans[cur], n) << '\n';
                cur = cur + 1;
                if (cur >= sz(ans)) cur--;
                cnt--;
            }
            return;
        }
    }
}

signed main() {
    int tt = 1;
    #ifdef LOCAL 
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        ios::sync_with_stdio(false); 
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB The values in the output sequence are not pairwise distinct!
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Fail, not exactly k bits are different: line = 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 1 ms 504 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 1 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 7080 KB Ok
2 Incorrect 25 ms 3708 KB Fail, not exactly k bits are different: line = 7
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Fail, not exactly k bits are different: line = 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 7072 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 7080 KB Ok
2 Incorrect 25 ms 3708 KB Fail, not exactly k bits are different: line = 7
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 3592 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -