# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120199 | AtabayRajabli | Palindrome-Free Numbers (BOI13_numbers) | C++17 | 1115 ms | 131072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
const int mod = 1e9 + 7;
map<string, bool> mp;
bool pal(string s)
{
int i = 0, j = s.size() - 1;
while(i < j)
{
if(s[i] != s[j]) return 0;
i++, j--;
}
return 1;
}
int f(int x)
{
string s = to_string(x);
if(mp.find(s) != mp.end()) return mp[s];
for(int i = 0; i < s.size(); i++)
{
string t = "";
int j = i;
t += s[j++];
while(j < s.size())
{
t += s[j++];
if(pal(t)) return mp[s] = mp[t] = 0;
}
}
return mp[s] = 1;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int l, r, ans = 0;
cin >> l >> r;
while(l <= r)
{
ans += f(l++);
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |