답안 #395003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395003 2021-04-27T15:29:30 Z Nicholas_Patrick 수열 (BOI14_sequence) C++17
34 / 100
1000 ms 1276 KB
#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

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);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 5 ms 588 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 4 ms 588 KB Output is correct
15 Correct 4 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 25 ms 680 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Execution timed out 1093 ms 588 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 2 ms 716 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 8 ms 1092 KB Output is correct
8 Correct 6 ms 844 KB Output is correct
9 Correct 13 ms 1212 KB Output is correct
10 Correct 12 ms 1276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Execution timed out 1094 ms 796 KB Time limit exceeded
6 Halted 0 ms 0 KB -