# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
400014 |
2021-05-07T05:27:36 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) {
ll ret = 0;
if (SZ(req) == 1) {
FOR(i,0,9) if (req[0] & (1<<i)) {
ret = ret*10 + i;
}
} 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
ret = min(ret,solve(req2)*10 + d);
}
}
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) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
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 |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |