# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128695 | 2019-07-11T08:30:40 Z | E869120 | Binary Subsequences (info1cup17_binary) | C++14 | 900 ms | 17456 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1060 ms | 17456 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 257 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 254 ms | 480 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |