# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1157018 | fhvirus | Sequence (BOI14_sequence) | C++20 | 1096 ms | 1608 KiB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll solve(vi B, bool need) {
if (B.empty()) { return need ? 1 : 0; }
ll ans = 12345678900000ll;
rep (d, 0, 10) {
vi nB(sz(B));
bool useful = false;
rep (i, 0, sz(B)) {
int j = (d + i) / 10, k = (d + i) % 10;
nB[j] |= (B[i] & (~(1 << k)));
useful |= ((B[i] & (1 << k)) != 0);
}
if (not useful) continue;
while (not nB.empty() and nB.back() == 0) nB.pop_back();
ans = min(ans, solve(nB, d == 0) * 10 + d);
}
return ans;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |