# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
983303 | 2024-05-15T10:04:16 Z | canadavid1 | Sequence (BOI14_sequence) | C++14 | 76 ms | 2392 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++) { 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); 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 | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 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 | 1 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 500 KB | Output is correct |
2 | Correct | 1 ms | 444 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 1 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 | 15 ms | 600 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 | 53 ms | 1800 KB | Output is correct |
8 | Correct | 65 ms | 1112 KB | Output is correct |
9 | Correct | 76 ms | 2392 KB | Output is correct |
10 | Correct | 75 ms | 2392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 1316 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Incorrect | 0 ms | 348 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |