# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395003 | Nicholas_Patrick | Sequence (BOI14_sequence) | C++17 | 1094 ms | 1276 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 <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
long long pow10[16];
int masks[100000];
bool has(long long x, int y){
if(x<100000)
return masks[x]>>y&1;
if(y==0 and x/10000==0)
return true;
return (masks[x%100000]>>y&1) or has(x/100000, y);
}
int can(long long n, vector<int>& a){
int k=a.size();
int ret=0;
for(int i=0; i<k; i++){
if(not has(n+i, a[i]))
ret|=1<<a[i];
}
return ret;
}
int nod(int x){
int ret=1;
if(x>=100000000)
x/=100000000, ret+=8;
if(x>=10000)
x/=10000, ret+=4;
if(x>=100)
x/=100, ret+=2;
if(x>=10)
ret+=1;
return ret;
}
int main(){
pow10[0]=1;
for(int i=1; i<16; i++)
pow10[i]=pow10[i-1]*10;
masks[0]=0;
for(int i=1; i<10; i++)
masks[i]=1<<i;
for(int i=10; i<100000; i++)
masks[i]=masks[i/10]|1<<i%10;
int k;
scanf("%d", &k);
vector<int> a(k);
for(int& i: a)
scanf("%d", &i);
if(min_element(a.begin(), a.end())==max_element(a.begin(), a.end())){
if(a[0]==0){
for(int i=1;; i++){
if(pow10[i]/9>=k){
printf("%d\n", pow10[i]);
return 0;
}
}
}else if(a[0]==9){
for(int i=1;; i++){
if(pow10[i]/9>=k){
printf("%d\n", pow10[i]/9*8+1);
return 0;
}
}
}else{
for(int i=0;; i++){
if(pow10[i]>=k){
printf("%d\n", pow10[i]*a[0]);
return 0;
}
}
}
}
for(int i=1;; i++){
if(can(i, a)==0){
printf("%d\n", i);
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... |