답안 #1120199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120199 2024-11-28T06:31:00 Z AtabayRajabli Palindrome-Free Numbers (BOI13_numbers) C++17
25 / 100
1000 ms 131072 KB
#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

numbers.cpp: In function 'long long int f(long long int)':
numbers.cpp:24:22: 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]
   24 |     for(int i = 0; i < s.size(); i++)
      |                    ~~^~~~~~~~~~
numbers.cpp:29:17: 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]
   29 |         while(j < s.size())
      |               ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 240 ms 11360 KB Output is correct
4 Correct 82 ms 8172 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 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 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 68 ms 8072 KB Output is correct
15 Correct 59 ms 8124 KB Output is correct
16 Correct 4 ms 592 KB Output is correct
17 Correct 19 ms 3084 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 229 ms 11336 KB Output is correct
20 Correct 88 ms 8260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 72144 KB Time limit exceeded
2 Execution timed out 1066 ms 58696 KB Time limit exceeded
3 Execution timed out 1086 ms 43080 KB Time limit exceeded
4 Execution timed out 1087 ms 46736 KB Time limit exceeded
5 Execution timed out 1060 ms 110372 KB Time limit exceeded
6 Execution timed out 1069 ms 94368 KB Time limit exceeded
7 Execution timed out 1046 ms 131072 KB Time limit exceeded
8 Execution timed out 1115 ms 128596 KB Time limit exceeded
9 Execution timed out 1037 ms 95044 KB Time limit exceeded
10 Execution timed out 1076 ms 111176 KB Time limit exceeded
11 Execution timed out 1068 ms 79336 KB Time limit exceeded
12 Execution timed out 1090 ms 113636 KB Time limit exceeded
13 Execution timed out 1082 ms 114872 KB Time limit exceeded
14 Execution timed out 1073 ms 118756 KB Time limit exceeded
15 Execution timed out 1059 ms 107848 KB Time limit exceeded
16 Execution timed out 1070 ms 43308 KB Time limit exceeded
17 Runtime error 879 ms 131072 KB Execution killed with signal 9
18 Execution timed out 1065 ms 76640 KB Time limit exceeded
19 Execution timed out 1090 ms 125300 KB Time limit exceeded
20 Execution timed out 1071 ms 81616 KB Time limit exceeded
21 Execution timed out 1053 ms 43336 KB Time limit exceeded
22 Execution timed out 1062 ms 100776 KB Time limit exceeded
23 Execution timed out 1016 ms 60156 KB Time limit exceeded
24 Runtime error 880 ms 131072 KB Execution killed with signal 9
25 Execution timed out 1073 ms 63560 KB Time limit exceeded
26 Execution timed out 1051 ms 36936 KB Time limit exceeded
27 Execution timed out 1060 ms 81944 KB Time limit exceeded
28 Execution timed out 1069 ms 62676 KB Time limit exceeded
29 Runtime error 879 ms 131072 KB Execution killed with signal 9
30 Execution timed out 1056 ms 94132 KB Time limit exceeded
31 Execution timed out 1055 ms 44576 KB Time limit exceeded
32 Execution timed out 1070 ms 131072 KB Time limit exceeded
33 Execution timed out 1006 ms 43700 KB Time limit exceeded
34 Execution timed out 1063 ms 77920 KB Time limit exceeded
35 Execution timed out 1069 ms 43724 KB Time limit exceeded
36 Execution timed out 1035 ms 42340 KB Time limit exceeded
37 Execution timed out 1073 ms 73220 KB Time limit exceeded
38 Execution timed out 1058 ms 48200 KB Time limit exceeded
39 Execution timed out 1081 ms 46920 KB Time limit exceeded
40 Runtime error 837 ms 131072 KB Execution killed with signal 9
41 Execution timed out 1051 ms 45896 KB Time limit exceeded
42 Runtime error 908 ms 131072 KB Execution killed with signal 9
43 Execution timed out 1061 ms 76616 KB Time limit exceeded
44 Execution timed out 1045 ms 59244 KB Time limit exceeded
45 Execution timed out 1060 ms 70612 KB Time limit exceeded