답안 #1120207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1120207 2024-11-28T06:33:18 Z vjudge1 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 237 ms 11472 KB Output is correct
4 Correct 78 ms 8248 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 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 69 ms 8260 KB Output is correct
15 Correct 71 ms 8036 KB Output is correct
16 Correct 3 ms 592 KB Output is correct
17 Correct 18 ms 2896 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 233 ms 11372 KB Output is correct
20 Correct 59 ms 8164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 74768 KB Time limit exceeded
2 Execution timed out 1071 ms 63972 KB Time limit exceeded
3 Execution timed out 1055 ms 44732 KB Time limit exceeded
4 Execution timed out 1048 ms 42892 KB Time limit exceeded
5 Execution timed out 1059 ms 107456 KB Time limit exceeded
6 Execution timed out 1082 ms 80748 KB Time limit exceeded
7 Execution timed out 1093 ms 125988 KB Time limit exceeded
8 Execution timed out 1085 ms 125076 KB Time limit exceeded
9 Execution timed out 1049 ms 109892 KB Time limit exceeded
10 Execution timed out 1063 ms 114208 KB Time limit exceeded
11 Execution timed out 1087 ms 81000 KB Time limit exceeded
12 Execution timed out 1091 ms 127504 KB Time limit exceeded
13 Execution timed out 1067 ms 107400 KB Time limit exceeded
14 Execution timed out 1063 ms 114396 KB Time limit exceeded
15 Execution timed out 1055 ms 110224 KB Time limit exceeded
16 Execution timed out 1012 ms 39664 KB Time limit exceeded
17 Execution timed out 1006 ms 131072 KB Time limit exceeded
18 Execution timed out 1062 ms 89292 KB Time limit exceeded
19 Runtime error 947 ms 131072 KB Execution killed with signal 9
20 Execution timed out 1052 ms 83324 KB Time limit exceeded
21 Execution timed out 1063 ms 46484 KB Time limit exceeded
22 Execution timed out 1070 ms 101776 KB Time limit exceeded
23 Execution timed out 1050 ms 58188 KB Time limit exceeded
24 Execution timed out 1020 ms 131072 KB Time limit exceeded
25 Execution timed out 1040 ms 61768 KB Time limit exceeded
26 Execution timed out 1036 ms 45896 KB Time limit exceeded
27 Execution timed out 1059 ms 77184 KB Time limit exceeded
28 Execution timed out 1056 ms 65372 KB Time limit exceeded
29 Runtime error 815 ms 131072 KB Execution killed with signal 9
30 Execution timed out 1051 ms 111588 KB Time limit exceeded
31 Execution timed out 1057 ms 45896 KB Time limit exceeded
32 Runtime error 866 ms 131072 KB Execution killed with signal 9
33 Execution timed out 1060 ms 50664 KB Time limit exceeded
34 Execution timed out 1044 ms 78652 KB Time limit exceeded
35 Execution timed out 1070 ms 48148 KB Time limit exceeded
36 Execution timed out 1056 ms 44496 KB Time limit exceeded
37 Execution timed out 1045 ms 73940 KB Time limit exceeded
38 Execution timed out 1056 ms 49532 KB Time limit exceeded
39 Execution timed out 1062 ms 51808 KB Time limit exceeded
40 Runtime error 861 ms 131072 KB Execution killed with signal 9
41 Execution timed out 1051 ms 43752 KB Time limit exceeded
42 Runtime error 884 ms 131072 KB Execution killed with signal 9
43 Execution timed out 1076 ms 70984 KB Time limit exceeded
44 Execution timed out 1048 ms 55624 KB Time limit exceeded
45 Execution timed out 1065 ms 80680 KB Time limit exceeded