Submission #395003

#TimeUsernameProblemLanguageResultExecution timeMemory
395003Nicholas_PatrickSequence (BOI14_sequence)C++17
34 / 100
1094 ms1276 KiB
#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)

sequence.cpp: In function 'int main()':
sequence.cpp:54:15: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   54 |      printf("%d\n", pow10[i]);
      |              ~^     ~~~~~~~~
      |               |            |
      |               int          long long int
      |              %lld
sequence.cpp:61:15: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   61 |      printf("%d\n", pow10[i]/9*8+1);
      |              ~^     ~~~~~~~~~~~~~~
      |               |                 |
      |               int               long long int
      |              %lld
sequence.cpp:68:15: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   68 |      printf("%d\n", pow10[i]*a[0]);
      |              ~^
      |               |
      |               int
      |              %lld
sequence.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |  scanf("%d", &k);
      |  ~~~~~^~~~~~~~~~
sequence.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   49 |   scanf("%d", &i);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...