#include <bits/stdc++.h>
using namespace std;
bool isPalindrome(const string &str) {
string s1 = str.substr(0, str.size() / 2 + str.size() % 2);
string s2 = str.substr(str.size() / 2);
reverse(s2.begin(), s2.end());
return s1 == s2;
}
template <typename func> bool forAll(const string &str, const func &f) {
for (size_t i = 0; i < str.size(); i++) {
for (size_t j = 2; j <= str.size() - i; j++) {
string substr = str.substr(i, j);
if (f(substr)) {
return false;
}
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int a, b, ans = 0;
cin >> a >> b;
for (int i = a; i <= b; i++) {
string str = to_string(i);
if (forAll(str, isPalindrome)) {
ans++;
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
564 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Correct |
20 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
504 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
18 ms |
456 KB |
Output is correct |
15 |
Correct |
29 ms |
336 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
17 |
Correct |
12 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
20 |
Correct |
30 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1061 ms |
504 KB |
Time limit exceeded |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
504 KB |
Output isn't correct |
5 |
Execution timed out |
1093 ms |
336 KB |
Time limit exceeded |
6 |
Execution timed out |
1050 ms |
336 KB |
Time limit exceeded |
7 |
Execution timed out |
1047 ms |
336 KB |
Time limit exceeded |
8 |
Correct |
750 ms |
436 KB |
Output is correct |
9 |
Execution timed out |
1062 ms |
336 KB |
Time limit exceeded |
10 |
Execution timed out |
1060 ms |
336 KB |
Time limit exceeded |
11 |
Execution timed out |
1043 ms |
336 KB |
Time limit exceeded |
12 |
Execution timed out |
1059 ms |
336 KB |
Time limit exceeded |
13 |
Execution timed out |
1034 ms |
336 KB |
Time limit exceeded |
14 |
Execution timed out |
1084 ms |
500 KB |
Time limit exceeded |
15 |
Execution timed out |
1078 ms |
336 KB |
Time limit exceeded |
16 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
508 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
36 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
38 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
39 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
42 |
Correct |
1 ms |
336 KB |
Output is correct |
43 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
44 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
45 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |