답안 #173532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173532 2020-01-04T13:43:51 Z srvlt "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
80 ms 15228 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <pair <int, int>, null_type, less <pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define low_b lower_bound

#define endl "\n"
//#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

int n, k, t, s;

string tobit(int x) {
    string res = "";
    do {
        res += char((x & 1) + '0');
        x >>= 1;
    }   while (x);
    while (size(res) < n) {
        res += '0';
    }
    reverse(all(res));
    return res;
}

vector <int> vec, ans;
bool used[(1 << 18)];

void dfs(int v) {
    ans.pb(v);
    used[v] = true;
    for (auto i : vec) {
        if (!used[v ^ i]) {
            dfs(v ^ i);
            break;
        }
    }
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> k >> t;
    for (int i = 0; i < (1 << n); i++) {
        if (__builtin_popcount(i) == k) {
            vec.pb(i);
        }
    }
    string tmp;
    cin >> tmp;
    for (int i = 0; i < size(tmp); i++) {
        if (tmp[i] == '1') {
            s += (1 << (size(tmp) - i - 1));
        }
    }
    dfs(s);
    if (size(ans) < (1 << n)) {
        cout << -1;
        return;
    }
    cout << (1 << n) << endl;
    for (auto i : ans) {
        cout << tobit(i) << endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Ok
2 Correct 10 ms 5368 KB Ok
3 Correct 6 ms 3064 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 296 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 2 ms 504 KB Ok
8 Correct 6 ms 3000 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 14980 KB Ok
2 Correct 38 ms 7668 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 4 ms 760 KB Ok
3 Correct 39 ms 7548 KB Ok
4 Correct 20 ms 3968 KB Ok
5 Correct 2 ms 380 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 10 ms 2168 KB Ok
8 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 15228 KB Ok
2 Correct 79 ms 15088 KB Ok
3 Correct 78 ms 14968 KB Ok
4 Correct 38 ms 7796 KB Ok
5 Correct 38 ms 7580 KB Ok
6 Correct 20 ms 4024 KB Ok
7 Correct 20 ms 3960 KB Ok
8 Correct 10 ms 2268 KB Ok
9 Correct 10 ms 2296 KB Ok
10 Correct 6 ms 1272 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 2 ms 380 KB Ok
13 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 14980 KB Ok
2 Correct 38 ms 7668 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 4 ms 760 KB Ok
8 Correct 39 ms 7548 KB Ok
9 Correct 20 ms 3968 KB Ok
10 Correct 2 ms 380 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 10 ms 2168 KB Ok
13 Correct 2 ms 376 KB Ok
14 Correct 79 ms 15228 KB Ok
15 Correct 79 ms 15088 KB Ok
16 Correct 78 ms 14968 KB Ok
17 Correct 38 ms 7796 KB Ok
18 Correct 38 ms 7580 KB Ok
19 Correct 20 ms 4024 KB Ok
20 Correct 20 ms 3960 KB Ok
21 Correct 10 ms 2268 KB Ok
22 Correct 10 ms 2296 KB Ok
23 Correct 6 ms 1272 KB Ok
24 Correct 2 ms 376 KB Ok
25 Correct 2 ms 380 KB Ok
26 Correct 2 ms 376 KB Ok
27 Correct 79 ms 14984 KB Ok
28 Correct 38 ms 7572 KB Ok
29 Correct 79 ms 15188 KB Ok
30 Correct 6 ms 1272 KB Ok
31 Correct 2 ms 376 KB Ok
32 Correct 4 ms 760 KB Ok
33 Correct 10 ms 2168 KB Ok
34 Correct 2 ms 380 KB Ok
35 Correct 2 ms 376 KB Ok
36 Correct 2 ms 376 KB Ok
37 Correct 2 ms 376 KB Ok
38 Correct 39 ms 7544 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 7580 KB Ok
2 Correct 80 ms 15084 KB Ok
3 Correct 79 ms 15088 KB Ok
4 Correct 6 ms 1272 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 10 ms 2168 KB Ok
7 Correct 78 ms 15084 KB Ok
8 Correct 2 ms 376 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 376 KB Ok
11 Correct 20 ms 3960 KB Ok
12 Correct 41 ms 7664 KB Ok