# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
983336 | 2024-05-15T10:24:48 Z | canadavid1 | Sequence (BOI14_sequence) | C++14 | 125 ms | 2440 KB |
#include <iostream> #include <vector> #include <bitset> #include <string> using digits = std::bitset<10>; using u64 = unsigned long long; u64 min_valid(std::vector<digits> v) { if(v.size()==0) return 0; if(v.size()==1) { auto w = v[0]; u64 o = 0; if(w.none()) return 0; if(w.count()==1 && w[0]) return 10; int i = 1; while(!w[i]) i++; o = i; w[i] = 0; if(w[0]) o *= 10; for(int i = 1; i < 10; i++) { if(!w[i]) continue; o *= 10; o += i; } return o; } u64 min = (u64)-1; for(u64 ls = 0; ls < 10; ls++) { std::vector<digits> n; auto k = ls; n.emplace_back(); for(int i = 0; i < v.size(); i++) { auto r = v[i]; r[k] = 0; n.back() |= r; if(++k==10) { k = 0; n.emplace_back(); } } while(n.size()&&n.back().none()) n.pop_back(); if(n == v) continue; auto a = min_valid(n); if(a==0 && ls == 0 && v[0][0]) a++; min = std::min(10*a+ls,min); } return min; } u64 brute_force(std::vector<digits> v) { for(int i = 0; i < 1e6; i++) { bool kl = 1; for(int k = 0; k < v.size(); k++) { auto s = std::to_string(i+k); bool f = false; for (auto j : s) f |= v[k][j-'0']; if(!f) {kl=0;break;}; } if(kl) return i; } return -1; } int main() { int K; std::cin >> K; std::vector<digits> v(K); for(auto& i : v) {int j; std::cin >> j; i[j]=1;} auto a = min_valid(v); std::cout << a << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 436 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 432 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 424 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 432 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 432 KB | Output is correct |
17 | Correct | 2 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 2 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 2 ms | 348 KB | Output is correct |
23 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 14 ms | 604 KB | Output is correct |
3 | Correct | 14 ms | 604 KB | Output is correct |
4 | Correct | 7 ms | 604 KB | Output is correct |
5 | Correct | 7 ms | 604 KB | Output is correct |
6 | Correct | 7 ms | 596 KB | Output is correct |
7 | Correct | 54 ms | 1804 KB | Output is correct |
8 | Correct | 61 ms | 1112 KB | Output is correct |
9 | Correct | 77 ms | 2420 KB | Output is correct |
10 | Correct | 78 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 59 ms | 1332 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 77 ms | 2360 KB | Output is correct |
12 | Correct | 125 ms | 2412 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 436 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 2 ms | 600 KB | Output is correct |
20 | Correct | 2 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 432 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 2 ms | 348 KB | Output is correct |
26 | Correct | 2 ms | 344 KB | Output is correct |
27 | Correct | 14 ms | 860 KB | Output is correct |
28 | Correct | 16 ms | 604 KB | Output is correct |
29 | Correct | 8 ms | 604 KB | Output is correct |
30 | Correct | 8 ms | 600 KB | Output is correct |
31 | Correct | 7 ms | 348 KB | Output is correct |
32 | Correct | 54 ms | 1808 KB | Output is correct |
33 | Correct | 56 ms | 1104 KB | Output is correct |
34 | Correct | 82 ms | 2416 KB | Output is correct |
35 | Correct | 78 ms | 2396 KB | Output is correct |
36 | Correct | 110 ms | 1828 KB | Output is correct |
37 | Correct | 120 ms | 2440 KB | Output is correct |
38 | Correct | 72 ms | 1368 KB | Output is correct |
39 | Correct | 125 ms | 2396 KB | Output is correct |
40 | Correct | 124 ms | 2416 KB | Output is correct |