# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
400026 |
2021-05-07T07:15:45 Z |
lyc |
Sequence (BOI14_sequence) |
C++14 |
|
2 ms |
208 KB |
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long ll;
const int mxK = 1e5+5;
int K;
ll solve(vector<int>& req, bool fst) {
ll ret = 0;
if (SZ(req) == 1) {
bool zero = 0;
FOR(i,1,9) if (req[0] & (1<<i)) {
ret = ret*10 + i;
if ((req[0]&1) && !zero) {
ret = ret*10;
zero = 1;
}
}
if ((req[0]&1) && !zero && !fst) {
ret = 10;
}
} else {
ret = 1e18;
FOR(d,0,9){
vector<int> req2;
FOR(i,0,SZ(req)-1){
int cur = req[i] & (~(1<<((i+d)%10)));
if (i == 0 || (i+d)/10 != (i-1+d)/10) {
req2.push_back(cur);
} else {
req2.back() |= cur;
}
}
if (req == req2) continue; // corner case
ll cur = solve(req2,0)*10 + d;
if (cur == 0 && !fst) cur = 10;
ret = min(ret,cur);
}
}
return ret;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> K;
vector<int> req;
FOR(i,1,K){
int A; cin >> A;
req.push_back(1<<A);
}
cout << solve(req,1) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |