Submission #282973

# Submission time Handle Problem Language Result Execution time Memory
282973 2020-08-25T08:05:55 Z AKaan37 Palindrome-Free Numbers (BOI13_numbers) C++17
15 / 100
1000 ms 768 KB
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[30][6][15][15];
int cev;
string s;
vector<int> v,vv;

inline int f(int sira,int al,int last2,int last1){
	int cevv=0;
	if(sira==(int)v.size())return 1;
	//~ if(~dp[sira][al][last2][last1])return dp[sira][al][last2][last1];
	for(int i=0;i<=9;i++){
		if(al==0 && i>v[sira])break;
		if(i==last2 || i==last1)continue;
		//~ if(sira==0 && i==0)continue;
		int yes=0;
		if(i<v[sira])yes=1;
		cevv=(cevv+f(sira+1,max(yes,al),last1,i));
	}
	return dp[sira][al][last2][last1]=cevv;
}

inline int f1(int sira,int al,int last2,int last1){
	int cevv=0;
	//~ cout<<sira<<" : : "<<al<<" : : "<<last2<<" : : "<<last1<<endl;
	if(sira==(int)vv.size())return 1;
	//~ if(~dp[sira][al][last2][last1])return dp[sira][al][last2][last1];
	for(int i=0;i<=9;i++){
		if(al==0 && i>vv[sira])break;
		if(i==last2 || i==last1)continue;
		//~ if(sira==0 && i==0)continue;
		int yes=0;
		if(i<vv[sira])yes=1;
		cevv=(cevv+f1(sira+1,max(yes,al),last1,i));
	}
	return dp[sira][al][last2][last1]=cevv;
}

main(void){
	scanf("%lld %lld",&n,&m);
	n--;
	if(n==-1)flag=1;
	while(n){
		v.pb(n%10);
		n/=10;
	}
	while(m){
		vv.pb(m%10);
		m/=10;
	}
	reverse(v.begin(),v.end());
	reverse(vv.begin(),vv.end());
	memset(dp,-1,sizeof(dp));
	//~ if(n==-1)
	cev=-f(0,0,10,10);
	memset(dp,-1,sizeof(dp));
	if(flag)cev=0;
	//~ cout<<cev<<endl;
	printf("%lld\n",cev+f1(0,0,10,10));
	return 0;
}

Compilation message

numbers.cpp:67:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main(void){
      |          ^
numbers.cpp: In function 'int main()':
numbers.cpp:68:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |  scanf("%lld %lld",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 640 KB Output isn't correct
2 Incorrect 1 ms 640 KB Output isn't correct
3 Execution timed out 1071 ms 640 KB Time limit exceeded
4 Incorrect 1 ms 640 KB Output isn't correct
5 Incorrect 1 ms 640 KB Output isn't correct
6 Incorrect 1 ms 640 KB Output isn't correct
7 Incorrect 1 ms 640 KB Output isn't correct
8 Incorrect 1 ms 640 KB Output isn't correct
9 Correct 1 ms 640 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 1 ms 640 KB Output is correct
12 Correct 1 ms 640 KB Output is correct
13 Correct 1 ms 640 KB Output is correct
14 Incorrect 1 ms 640 KB Output isn't correct
15 Incorrect 2 ms 640 KB Output isn't correct
16 Correct 8 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 1 ms 640 KB Output is correct
19 Execution timed out 1088 ms 640 KB Time limit exceeded
20 Incorrect 1 ms 640 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 465 ms 688 KB Output is correct
2 Execution timed out 1096 ms 640 KB Time limit exceeded
3 Execution timed out 1092 ms 640 KB Time limit exceeded
4 Execution timed out 1088 ms 640 KB Time limit exceeded
5 Incorrect 199 ms 640 KB Output isn't correct
6 Correct 634 ms 760 KB Output is correct
7 Incorrect 11 ms 640 KB Output isn't correct
8 Incorrect 9 ms 768 KB Output isn't correct
9 Incorrect 14 ms 640 KB Output isn't correct
10 Incorrect 19 ms 640 KB Output isn't correct
11 Correct 461 ms 640 KB Output is correct
12 Incorrect 111 ms 760 KB Output isn't correct
13 Incorrect 30 ms 640 KB Output isn't correct
14 Incorrect 196 ms 760 KB Output isn't correct
15 Incorrect 225 ms 640 KB Output isn't correct
16 Execution timed out 1091 ms 640 KB Time limit exceeded
17 Execution timed out 1084 ms 640 KB Time limit exceeded
18 Execution timed out 1088 ms 640 KB Time limit exceeded
19 Execution timed out 1091 ms 640 KB Time limit exceeded
20 Execution timed out 1075 ms 640 KB Time limit exceeded
21 Execution timed out 1088 ms 640 KB Time limit exceeded
22 Execution timed out 1092 ms 640 KB Time limit exceeded
23 Execution timed out 1089 ms 640 KB Time limit exceeded
24 Execution timed out 1089 ms 640 KB Time limit exceeded
25 Execution timed out 1096 ms 640 KB Time limit exceeded
26 Execution timed out 1091 ms 640 KB Time limit exceeded
27 Execution timed out 1094 ms 640 KB Time limit exceeded
28 Execution timed out 1074 ms 640 KB Time limit exceeded
29 Execution timed out 1092 ms 640 KB Time limit exceeded
30 Execution timed out 1085 ms 640 KB Time limit exceeded
31 Execution timed out 1086 ms 640 KB Time limit exceeded
32 Execution timed out 1089 ms 640 KB Time limit exceeded
33 Execution timed out 1095 ms 640 KB Time limit exceeded
34 Execution timed out 1049 ms 640 KB Time limit exceeded
35 Execution timed out 1082 ms 636 KB Time limit exceeded
36 Execution timed out 1094 ms 640 KB Time limit exceeded
37 Execution timed out 1084 ms 640 KB Time limit exceeded
38 Execution timed out 1096 ms 640 KB Time limit exceeded
39 Execution timed out 1090 ms 640 KB Time limit exceeded
40 Execution timed out 1076 ms 640 KB Time limit exceeded
41 Execution timed out 1089 ms 640 KB Time limit exceeded
42 Execution timed out 1090 ms 640 KB Time limit exceeded
43 Execution timed out 1091 ms 640 KB Time limit exceeded
44 Execution timed out 1068 ms 640 KB Time limit exceeded
45 Execution timed out 1092 ms 640 KB Time limit exceeded