# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982670 | 2024-05-14T15:40:38 Z | canadavid1 | Sequence (BOI14_sequence) | C++14 | 72 ms | 2412 KB |
#include <iostream> #include <vector> #include <bitset> 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++) { if(ls==9 && v.size()==2 && !v[0][9] && !v[1][0]) break; 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(); } } if(n.back().none()) n.pop_back(); auto a = min_valid(n); min = std::min(10*a+ls,min); } return min; } int main() { int K; std::cin >> K; std::vector<digits> v(K); for(auto& i : v) {int j; std::cin >> j; i[j]=1;} std::cout << min_valid(v) << "\n"; }
Compilation message
# | 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 | Incorrect | 0 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Incorrect | 0 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 14 ms | 660 KB | Output is correct |
3 | Correct | 14 ms | 600 KB | Output is correct |
4 | Correct | 7 ms | 604 KB | Output is correct |
5 | Correct | 7 ms | 604 KB | Output is correct |
6 | Correct | 6 ms | 348 KB | Output is correct |
7 | Correct | 50 ms | 1800 KB | Output is correct |
8 | Correct | 56 ms | 1360 KB | Output is correct |
9 | Correct | 72 ms | 2412 KB | Output is correct |
10 | Correct | 70 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 53 ms | 1276 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Incorrect | 1 ms | 348 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |