Submission #1120223

# Submission time Handle Problem Language Result Execution time Memory
1120223 2024-11-28T06:37:24 Z vjudge1 Palindrome-Free Numbers (BOI13_numbers) C++17
20 / 100
1000 ms 788 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld double


const int INF = 1e18;
const int mod = 12345;
const int sz = 1e5 + 5;

bool pal(string z)
{
    int x = stoi(z);
    int xc = x;
    int cur = 1;
    int res = 0;
    while(xc > 0)
    {
        res += (cur * (xc % 10));
        cur *= 10;
        xc /= 10;
    }
    return res == x;
}

bool f(int x)
{
    string s;
    s = to_string(x);
    for(int i = 0;i < s.size() - 1;i++)
    {
        string c = "";
        c += s[i];
        for(int j = i + 1;j < s.size();j++)
        {
            c += s[j];
            if(c[0] == c[c.size() - 1] && c[1] == c[c.size() - 2]){
                    if(pal(c)) return false;
            }
        }
    }
    return true;
}

signed main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);
   int a , b;
   cin >> a >> b;
   int ans = 0;
   for(int i = a;i <= b;i++)
   {
       if(f(i))
       {
           ans++;
       }
   }
   cout << ans  << endl;
}

Compilation message

numbers.cpp: In function 'bool f(long long int)':
numbers.cpp:31:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0;i < s.size() - 1;i++)
      |                   ~~^~~~~~~~~~~~~~
numbers.cpp:35:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = i + 1;j < s.size();j++)
      |                           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Runtime error 3 ms 592 KB Execution killed with signal 6
4 Correct 9 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 348 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 504 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 9 ms 456 KB Output is correct
15 Correct 8 ms 336 KB Output is correct
16 Incorrect 2 ms 460 KB Output isn't correct
17 Incorrect 4 ms 336 KB Output isn't correct
18 Correct 1 ms 336 KB Output is correct
19 Runtime error 3 ms 592 KB Execution killed with signal 6
20 Correct 9 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 336 KB Time limit exceeded
2 Runtime error 3 ms 592 KB Execution killed with signal 6
3 Runtime error 2 ms 520 KB Execution killed with signal 6
4 Runtime error 4 ms 592 KB Execution killed with signal 6
5 Execution timed out 1044 ms 336 KB Time limit exceeded
6 Execution timed out 1056 ms 336 KB Time limit exceeded
7 Incorrect 442 ms 444 KB Output isn't correct
8 Incorrect 318 ms 336 KB Output isn't correct
9 Incorrect 484 ms 440 KB Output isn't correct
10 Incorrect 686 ms 504 KB Output isn't correct
11 Execution timed out 1046 ms 336 KB Time limit exceeded
12 Execution timed out 1050 ms 336 KB Time limit exceeded
13 Execution timed out 1048 ms 336 KB Time limit exceeded
14 Execution timed out 1047 ms 336 KB Time limit exceeded
15 Execution timed out 1066 ms 336 KB Time limit exceeded
16 Runtime error 4 ms 592 KB Execution killed with signal 6
17 Execution timed out 1054 ms 336 KB Time limit exceeded
18 Runtime error 4 ms 608 KB Execution killed with signal 6
19 Execution timed out 1093 ms 336 KB Time limit exceeded
20 Runtime error 3 ms 592 KB Execution killed with signal 6
21 Runtime error 2 ms 592 KB Execution killed with signal 6
22 Runtime error 3 ms 592 KB Execution killed with signal 6
23 Runtime error 3 ms 592 KB Execution killed with signal 6
24 Execution timed out 1093 ms 336 KB Time limit exceeded
25 Runtime error 3 ms 764 KB Execution killed with signal 6
26 Runtime error 3 ms 788 KB Execution killed with signal 6
27 Runtime error 3 ms 592 KB Execution killed with signal 6
28 Runtime error 4 ms 592 KB Execution killed with signal 6
29 Execution timed out 1100 ms 336 KB Time limit exceeded
30 Runtime error 3 ms 592 KB Execution killed with signal 6
31 Runtime error 4 ms 592 KB Execution killed with signal 6
32 Execution timed out 1054 ms 336 KB Time limit exceeded
33 Runtime error 3 ms 764 KB Execution killed with signal 6
34 Runtime error 2 ms 592 KB Execution killed with signal 6
35 Runtime error 4 ms 592 KB Execution killed with signal 6
36 Runtime error 3 ms 592 KB Execution killed with signal 6
37 Runtime error 3 ms 520 KB Execution killed with signal 6
38 Runtime error 3 ms 620 KB Execution killed with signal 6
39 Runtime error 3 ms 592 KB Execution killed with signal 6
40 Execution timed out 1051 ms 336 KB Time limit exceeded
41 Runtime error 3 ms 592 KB Execution killed with signal 6
42 Execution timed out 1096 ms 336 KB Time limit exceeded
43 Runtime error 3 ms 592 KB Execution killed with signal 6
44 Runtime error 3 ms 592 KB Execution killed with signal 6
45 Runtime error 3 ms 592 KB Execution killed with signal 6