Submission #77211

# Submission time Handle Problem Language Result Execution time Memory
77211 2018-09-24T01:52:09 Z Dat160601 Palindrome-Free Numbers (BOI13_numbers) C++17
73.75 / 100
23 ms 704 KB
#include <bits/stdc++.h>
using namespace std;
long long a,b;
long long len_a=0,len_b=0;
long long digit_a[20],digit_b[20];
long long dp[20][2][2][11][11];
long long go(int id,int l,int r,int prv,int pv){
	if(id==0) return 1LL;
	if(dp[id][l][r][prv][pv]!=-1) return dp[id][l][r][prv][pv];
	long long ret=0;
	for(int i=0;i<=9;i++){
		if(l==1 && i<digit_a[id]) continue;
		if(r==1 && i>digit_b[id]) continue;
		if(i==prv || i==pv) continue;
		ret+=go(id-1,(l==1 && i==digit_a[id])?1:0,(r==1 && i==digit_b[id])?1:0,pv,i);
	}
	dp[id][l][r][prv][pv]=ret;
	return ret;
}
int main(){
	scanf("%lld %lld",&a,&b);
	long long x=a;
	while(x>0){
		digit_a[++len_a]=x%10;
		x/=10;
	}
	x=b;
	while(x>0){
		digit_b[++len_b]=x%10;
		x/=10;
	}
	memset(dp,-1,sizeof(dp));
	long long ans=0;
	for(int i=len_b;i>=len_a;i--) ans+=go(i,1,1,10,10);
	printf("%lld",ans);
}

Compilation message

numbers.cpp: In function 'int main()':
numbers.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 500 KB Output isn't correct
3 Correct 2 ms 500 KB Output is correct
4 Incorrect 2 ms 596 KB Output isn't correct
5 Correct 2 ms 596 KB Output is correct
6 Incorrect 2 ms 596 KB Output isn't correct
7 Incorrect 2 ms 596 KB Output isn't correct
8 Incorrect 2 ms 596 KB Output isn't correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 2 ms 620 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Incorrect 2 ms 620 KB Output isn't correct
15 Incorrect 2 ms 620 KB Output isn't correct
16 Correct 2 ms 636 KB Output is correct
17 Correct 2 ms 636 KB Output is correct
18 Correct 2 ms 636 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Incorrect 2 ms 640 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 23 ms 640 KB Output is correct
5 Incorrect 2 ms 640 KB Output isn't correct
6 Correct 2 ms 640 KB Output is correct
7 Incorrect 2 ms 640 KB Output isn't correct
8 Incorrect 2 ms 640 KB Output isn't correct
9 Incorrect 2 ms 640 KB Output isn't correct
10 Incorrect 2 ms 640 KB Output isn't correct
11 Correct 2 ms 640 KB Output is correct
12 Incorrect 2 ms 640 KB Output isn't correct
13 Incorrect 2 ms 640 KB Output isn't correct
14 Incorrect 2 ms 640 KB Output isn't correct
15 Incorrect 2 ms 640 KB Output isn't correct
16 Correct 2 ms 640 KB Output is correct
17 Correct 2 ms 640 KB Output is correct
18 Correct 2 ms 640 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 2 ms 640 KB Output is correct
21 Correct 2 ms 640 KB Output is correct
22 Correct 2 ms 704 KB Output is correct
23 Correct 2 ms 704 KB Output is correct
24 Correct 2 ms 704 KB Output is correct
25 Correct 3 ms 704 KB Output is correct
26 Correct 2 ms 704 KB Output is correct
27 Correct 2 ms 704 KB Output is correct
28 Correct 2 ms 704 KB Output is correct
29 Correct 2 ms 704 KB Output is correct
30 Correct 2 ms 704 KB Output is correct
31 Correct 2 ms 704 KB Output is correct
32 Correct 2 ms 704 KB Output is correct
33 Correct 2 ms 704 KB Output is correct
34 Correct 2 ms 704 KB Output is correct
35 Correct 2 ms 704 KB Output is correct
36 Correct 2 ms 704 KB Output is correct
37 Correct 2 ms 704 KB Output is correct
38 Correct 2 ms 704 KB Output is correct
39 Correct 2 ms 704 KB Output is correct
40 Correct 2 ms 704 KB Output is correct
41 Correct 2 ms 704 KB Output is correct
42 Correct 2 ms 704 KB Output is correct
43 Correct 2 ms 704 KB Output is correct
44 Correct 2 ms 704 KB Output is correct
45 Correct 2 ms 704 KB Output is correct