# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128695 | E869120 | Binary Subsequences (info1cup17_binary) | C++14 | 1060 ms | 17456 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)
int len[250], mask[250];
void hantei(int dig, int masks) {
vector<int>P[20];
for (int i = 0; i < dig; i++) {
int s = 0;
for (int j = i; j < dig; j++) {
// 区間 [i, j]
s += (1 << j);
P[j - i].push_back(masks&s);
}
}
int cnt = 0;
for (int i = 0; i < dig; i++) {
sort(P[i].begin(), P[i].end());
P[i].erase(unique(P[i].begin(), P[i].end()), P[i].end());
cnt += P[i].size();
}
if (len[cnt] > dig) {
len[cnt] = dig;
mask[cnt] = masks;
}
}
void init() {
for (int i = 0; i < 250; i++) { len[i] = (1 << 30); mask[i] = -1; }
for (int i = 1; i <= 15; i++) {
for (int j = 0; j < (1 << i); j++) hantei(i, j);
}
}
void solve(int A) {
if (A >= 250 || len[A] == 0) {
cout << "-1" << endl;
cout << "-1" << endl;
}
else {
cout << len[A] << endl;
for (int i = 0; i < len[A]; i++) {
if (i) cout << " ";
cout << (mask[A] / (1 << i)) % 2;
}
cout << endl;
}
}
int main() {
init();
int T; scanf("%d", &T);
for (int i = 1; i <= T; i++) {
int K; scanf("%d", &K);
solve(K);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |