# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134447 | 2019-07-22T17:12:54 Z | Kastanda | Sequence (BOI14_sequence) | C++11 | 538 ms | 856 KB |
// ItnoE #include<bits/stdc++.h> using namespace std; typedef long long ll; inline ll Solve(vector < int > A, bool w, int dp) { int n = (int)A.size(); if (dp > 15) return (-1); if (n == 0) return (!w); if (n == 1) { if (A[0] == 0) return (!w); ll rs = 0; for (int i = 1; i <= 9; i ++) if (A[0] >> i & 1) { rs = rs * 10 + i; if (A[0] & 1) rs *= 10, A[0] ^= 1; } if (!rs) rs = 10; return (rs); } ll rs = LLONG_MAX; for (int i = 0; i <= 9; i ++) { int d = i, k = 0; vector < int > B; for (int j = 0; j < n; j ++) { if (j && !d) B.push_back(k), k = 0; k |= A[j] ^ (A[j] & (1 << d)); d ++; if (d >= 10) d -= 10; } B.push_back(k); ll rt = Solve(B, w | (i > 0), dp + 1); if (rt != -1) rs = min(rs, rt * 10 + i); } return (rs); } int main() { int n; scanf("%d", &n); vector < int > A(n); for (int &a : A) scanf("%d", &a), a = 1 << a; return !printf("%lld\n", Solve(A, 0, 0)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 4 ms | 380 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Incorrect | 16 ms | 428 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 8 ms | 256 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 15 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Incorrect | 15 ms | 256 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 140 ms | 504 KB | Output is correct |
3 | Correct | 140 ms | 504 KB | Output is correct |
4 | Incorrect | 139 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 360 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 538 ms | 856 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 16 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Incorrect | 15 ms | 376 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |