#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pi;
typedef map<ll,ll> mi;
typedef long double ld;
typedef vector<ld> vd;
typedef vector<vector<ld>> vvd;
typedef pair<ld,ld> pd;
#define ff first
#define ss second
#define srt(a) sort(a.begin(),a.end());
#define fip(k, n) for (ll i = k; i < n; i++)
#define fjp(k, n) for (ll j = k; j < n; j++)
#define fin(k, n) for (ll i = k; i >= n; i--)
#define fjn(k, n) for (ll j = k; j >= n; j--)
#define fp(k, n, m) for (ll k = n; k < m; k++)
#define fn(k, n, m) for (ll k = n; k >= m; k--)
#define ordered_set tree<pi, null_type,less< pi >, rb_tree_tag,tree_order_statistics_node_update>
#define totalOne(n) __builtin_popcount(n)
#define backZero(n) __builtin_ctzll(n)
#define frontZero(n) __builtin_clzll(n)
#define fx(k) for ( auto x : k )
#define test ll t;cin >> t;while (t--)
#define nli "\n"
// ==========================(debug)============================================================================================== //
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _printn(x); cerr << nli;
#else
#define debug(x)
#endif
void _printn(ll x){ cerr<<x<<" "; }
void _printn(int x){ cerr<<x<<" "; }
void _printn(ld x){ cerr<<x<<" "; }
void _printn(double x){ cerr<<x<<" "; }
void _printn(string x){ cerr<<x<<" "; }
void _printn(char x){ cerr<<x<<" "; }
void _printn(bool x){ cerr<<x<<" "; }
template<class T,class V>void _printn(pair<T,V> vv);
template<class T> void _printn(vector<T> vv);
template<class T> void _printn(set<T> vv);
template<class T,class V> void _printn(map<T,V> vv);
template<class T> void _printn(multiset<T> vv);
template<class T,class V>void _printn(pair<T,V> vv){ cerr<<"( ";_printn(vv.ff);cerr<<",";_printn(vv.ss);cerr<<")";}
template<class T> void _printn(vector<T> vv){ cerr<<"[ "; for(auto xx:vv){ _printn(xx);cerr<<" "; } cerr<<"]"; };
template<class T> void _printn(set<T> vv){ cerr<<"{ "; for(auto xx:vv){ _printn(xx);cerr<<" "; } cerr<<"}"; };
template<class T> void _printn(multiset<T> vv){ cerr<<"{ "; for(auto xx:vv){ _printn(xx);cerr<<" "; } cerr<<"}"; };
template<class T,class V> void _printn(map<T,V> vv){ cerr<<"{ "; for(auto xx:vv){ _printn(xx);cerr<<" "; } cerr<<"}"; };
// ==========================(debug)============================================================================================== //
ll n,m,tp,tp2,res,cnt,sum,tptp,ans;
const ll mx = 15;
const ll mod = 1e9+7;
// ==========================(MOD)=============================================================================================== //
ll mod_add(ll aa,ll bb){ return ((aa%mod)+(bb%mod))%mod; }
ll mod_minus(ll aa,ll bb){ return (((aa%mod)-(bb%mod))+10*mod)%mod; }
ll mod_mul(ll aa,ll bb){ return ((aa%mod)*(bb%mod))%mod; }
ll mod_power(ll aa,ll bb){ aa%=mod; ll empowered = 1; bb%=mod-1; while(bb > 0){ if(bb & 1) empowered = mod_mul(empowered,aa); bb = bb >> 1; aa = mod_mul(aa,aa); } return empowered; }
ll mod_divi(ll aa,ll bb){ aa=mod_mul(aa,mod_power(bb,mod-2)); return aa; }
// ==========================(MOD)=============================================================================================== //
bool f = false;
string k1,k2;
ll dp[mx][mx];
ll lcs(ll ptr1,ll ptr2){
if(ptr1 == 0 || ptr2 == 0)
return 0;
if(dp[ptr1][ptr2]!=-1)
return dp[ptr1][ptr2];
if(k1[ptr1-1] == k2[ptr2-1])
return dp[ptr1][ptr2] = 1 + lcs(ptr1-1,ptr2-1);
else
return dp[ptr1][ptr2] = max(lcs(ptr1,ptr2-1),lcs(ptr1-1,ptr2));
}
bool calc(){
memset(dp,-1,sizeof(dp));
tptp = lcs(tp,tp);
return (tptp<2);
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input1.txt", "r", stdin);
// freopen("output1.txt", "w", stdout);
// freopen("error1.txt", "w", stderr);
// #endif // ONLINE_JUDGE
cin>>n>>m;
cnt = 0;
fip(n,m+1){
k1 = to_string(i);
k2 = k1;
reverse(k2.begin(),k2.end());
tp = k2.size();
if(calc())
cnt++;
}
cout<<cnt<<nli;
// cerr << "Time elapsed: " << setprecision(6) << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
15 ms |
212 KB |
Output isn't correct |
4 |
Incorrect |
21 ms |
212 KB |
Output isn't correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Incorrect |
21 ms |
320 KB |
Output isn't correct |
15 |
Incorrect |
21 ms |
212 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
324 KB |
Output isn't correct |
17 |
Incorrect |
10 ms |
324 KB |
Output isn't correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Incorrect |
16 ms |
324 KB |
Output isn't correct |
20 |
Incorrect |
21 ms |
328 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
212 KB |
Time limit exceeded |
2 |
Execution timed out |
1061 ms |
212 KB |
Time limit exceeded |
3 |
Execution timed out |
1071 ms |
212 KB |
Time limit exceeded |
4 |
Execution timed out |
1073 ms |
212 KB |
Time limit exceeded |
5 |
Execution timed out |
1079 ms |
212 KB |
Time limit exceeded |
6 |
Execution timed out |
1071 ms |
212 KB |
Time limit exceeded |
7 |
Execution timed out |
1078 ms |
212 KB |
Time limit exceeded |
8 |
Incorrect |
777 ms |
300 KB |
Output isn't correct |
9 |
Execution timed out |
1080 ms |
212 KB |
Time limit exceeded |
10 |
Execution timed out |
1048 ms |
212 KB |
Time limit exceeded |
11 |
Execution timed out |
1076 ms |
212 KB |
Time limit exceeded |
12 |
Execution timed out |
1084 ms |
212 KB |
Time limit exceeded |
13 |
Execution timed out |
1075 ms |
212 KB |
Time limit exceeded |
14 |
Execution timed out |
1078 ms |
212 KB |
Time limit exceeded |
15 |
Execution timed out |
1084 ms |
212 KB |
Time limit exceeded |
16 |
Execution timed out |
1071 ms |
212 KB |
Time limit exceeded |
17 |
Execution timed out |
1082 ms |
212 KB |
Time limit exceeded |
18 |
Execution timed out |
1079 ms |
212 KB |
Time limit exceeded |
19 |
Execution timed out |
1078 ms |
212 KB |
Time limit exceeded |
20 |
Execution timed out |
1048 ms |
212 KB |
Time limit exceeded |
21 |
Execution timed out |
1059 ms |
212 KB |
Time limit exceeded |
22 |
Execution timed out |
1073 ms |
212 KB |
Time limit exceeded |
23 |
Execution timed out |
1072 ms |
212 KB |
Time limit exceeded |
24 |
Execution timed out |
1071 ms |
212 KB |
Time limit exceeded |
25 |
Execution timed out |
1066 ms |
212 KB |
Time limit exceeded |
26 |
Execution timed out |
1077 ms |
212 KB |
Time limit exceeded |
27 |
Execution timed out |
1070 ms |
212 KB |
Time limit exceeded |
28 |
Execution timed out |
1076 ms |
212 KB |
Time limit exceeded |
29 |
Execution timed out |
1078 ms |
212 KB |
Time limit exceeded |
30 |
Execution timed out |
1088 ms |
212 KB |
Time limit exceeded |
31 |
Execution timed out |
1042 ms |
212 KB |
Time limit exceeded |
32 |
Execution timed out |
1065 ms |
212 KB |
Time limit exceeded |
33 |
Execution timed out |
1065 ms |
212 KB |
Time limit exceeded |
34 |
Execution timed out |
1074 ms |
212 KB |
Time limit exceeded |
35 |
Execution timed out |
1083 ms |
212 KB |
Time limit exceeded |
36 |
Execution timed out |
1035 ms |
212 KB |
Time limit exceeded |
37 |
Execution timed out |
1068 ms |
212 KB |
Time limit exceeded |
38 |
Execution timed out |
1065 ms |
212 KB |
Time limit exceeded |
39 |
Execution timed out |
1074 ms |
212 KB |
Time limit exceeded |
40 |
Execution timed out |
1072 ms |
212 KB |
Time limit exceeded |
41 |
Execution timed out |
1085 ms |
212 KB |
Time limit exceeded |
42 |
Execution timed out |
1074 ms |
212 KB |
Time limit exceeded |
43 |
Execution timed out |
1063 ms |
212 KB |
Time limit exceeded |
44 |
Execution timed out |
1081 ms |
212 KB |
Time limit exceeded |
45 |
Execution timed out |
1082 ms |
212 KB |
Time limit exceeded |