답안 #832070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832070 2023-08-20T21:55:32 Z allw Palindrome-Free Numbers (BOI13_numbers) C++17
13.75 / 100
1000 ms 340 KB
#include <algorithm>
#include <cstdio>
#include <vector>
#include <iostream>
#include <map>
#include <cstring>

#define LOCAL true

/*
    Author: Oleksii Renov
*/

using namespace std;
using ll = long long int;

int dp[100];

ll run(int pos, int last1, int last2, bool smaller, bool started, const string& x) {
    if (pos == x.size()) {
        return 1;
    }

    int end = smaller ? 9 : (x[pos] - '0');
    ll cnt = 0;
    for (int i = 0; i <= end; ++i) {
        if (!started && i == 0) continue;
        if (i != last1 && i != last2) {
            cnt += run(pos + 1, i, last1, smaller || (i != end), started || (i != 0), x);
        }
    }
    return cnt;
}

int main() {
    ll a, b;
    cin >> a >> b;
    memset(dp, -1, sizeof(dp));
    ll cnt1 = run(0, 10, 10, false, false, to_string(b));
    memset(dp, -1, sizeof(dp));
    ll cnt2 = run(0, 10, 10, false, false, to_string(a-1));
    std::cout << cnt1 - cnt2 << '\n';
}

Compilation message

numbers.cpp: In function 'll run(int, int, int, bool, bool, const string&)':
numbers.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     if (pos == x.size()) {
      |         ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Execution timed out 1071 ms 212 KB Time limit exceeded
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Correct 4 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Execution timed out 1080 ms 212 KB Time limit exceeded
20 Incorrect 1 ms 212 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 212 KB Output is correct
2 Execution timed out 1073 ms 212 KB Time limit exceeded
3 Execution timed out 1073 ms 212 KB Time limit exceeded
4 Execution timed out 1082 ms 212 KB Time limit exceeded
5 Incorrect 87 ms 212 KB Output isn't correct
6 Correct 122 ms 276 KB Output is correct
7 Incorrect 4 ms 212 KB Output isn't correct
8 Incorrect 3 ms 212 KB Output isn't correct
9 Incorrect 6 ms 212 KB Output isn't correct
10 Incorrect 8 ms 212 KB Output isn't correct
11 Correct 36 ms 300 KB Output is correct
12 Incorrect 43 ms 212 KB Output isn't correct
13 Incorrect 14 ms 212 KB Output isn't correct
14 Incorrect 86 ms 212 KB Output isn't correct
15 Incorrect 105 ms 284 KB Output isn't correct
16 Execution timed out 1092 ms 212 KB Time limit exceeded
17 Execution timed out 1077 ms 212 KB Time limit exceeded
18 Execution timed out 1084 ms 212 KB Time limit exceeded
19 Execution timed out 1067 ms 212 KB Time limit exceeded
20 Execution timed out 1074 ms 212 KB Time limit exceeded
21 Execution timed out 1089 ms 212 KB Time limit exceeded
22 Execution timed out 1088 ms 212 KB Time limit exceeded
23 Execution timed out 1092 ms 212 KB Time limit exceeded
24 Execution timed out 1083 ms 212 KB Time limit exceeded
25 Execution timed out 1052 ms 212 KB Time limit exceeded
26 Execution timed out 1081 ms 212 KB Time limit exceeded
27 Execution timed out 1073 ms 212 KB Time limit exceeded
28 Execution timed out 1078 ms 212 KB Time limit exceeded
29 Execution timed out 1070 ms 232 KB Time limit exceeded
30 Execution timed out 1082 ms 212 KB Time limit exceeded
31 Execution timed out 1072 ms 212 KB Time limit exceeded
32 Execution timed out 1081 ms 212 KB Time limit exceeded
33 Execution timed out 1079 ms 212 KB Time limit exceeded
34 Execution timed out 1083 ms 212 KB Time limit exceeded
35 Execution timed out 1079 ms 212 KB Time limit exceeded
36 Execution timed out 1074 ms 212 KB Time limit exceeded
37 Execution timed out 1077 ms 212 KB Time limit exceeded
38 Execution timed out 1076 ms 212 KB Time limit exceeded
39 Execution timed out 1077 ms 212 KB Time limit exceeded
40 Execution timed out 1081 ms 212 KB Time limit exceeded
41 Execution timed out 1080 ms 212 KB Time limit exceeded
42 Execution timed out 1076 ms 212 KB Time limit exceeded
43 Execution timed out 1084 ms 212 KB Time limit exceeded
44 Execution timed out 1074 ms 212 KB Time limit exceeded
45 Execution timed out 1068 ms 212 KB Time limit exceeded