답안 #394999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394999 2021-04-27T15:25:58 Z Nicholas_Patrick 수열 (BOI14_sequence) C++17
9 / 100
1000 ms 844 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]){
			for(int i=0;; i++){
				if(pow10[i]>=k){
					printf("%d\n", pow10[i]*a[0]);
					return 0;
				}
			}
		}else{
			for(int i=1;; i++){
				if(pow10[i]/9>=k){
					printf("%d\n", pow10[i]);
					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]*a[0]);
      |              ~^
      |               |
      |               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]);
      |              ~^     ~~~~~~~~
      |               |            |
      |               int          long long 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 676 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 4 ms 680 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 1 ms 676 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 676 KB Output is correct
14 Correct 3 ms 588 KB Output is correct
15 Correct 3 ms 588 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 23 ms 588 KB Output is correct
8 Correct 1 ms 684 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 1094 ms 588 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Incorrect 2 ms 716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 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 676 KB Output is correct
5 Execution timed out 1094 ms 844 KB Time limit exceeded
6 Halted 0 ms 0 KB -