# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107800 | dfistric | Sequence (BOI14_sequence) | C++14 | 274 ms | 1532 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;
ll rek(vector <int> ve, int flag) {
if (ve.size() == 1) {
ll out = 0;
int a = ve[0];
FOR(i, 1, 10) {
if (a & (1 << i)) out = out * 10 + i;
if (out == i && (a & 1)) out *= 10;
}
if (out == 0 && (a & 1)) out = 10;
return out;
}
ll out = 102345678900000LL;
REP(n, 9 + flag) {
int y = n, fl = 0, tr = 0;
vector <int> tmp;
REP(i, ve.size()) {
int a = ve[i];
tr |= ((1023 ^ (1 << y)) & a);
if (y == 0 && (a & 1)) fl = 1;
y = (y + 1) % 10;
if (y == 0 || i == ve.size() - 1) tmp.push_back(tr), tr = 0;
}
ll curr = rek(tmp, n < 9 || ve.size() > 2) * 10 + n;
if (curr == 0 && fl) curr = 10;
out = min(out, curr);
}
return out;
}
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector <int> tmp;
REP(i, n) {
int x;
cin >> x;
tmp.push_back((1 << x));
}
cout << rek(tmp, 1) << endl;
return 0;
}
Compilation message (stderr)
# | 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... |