답안 #373939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373939 2021-03-06T08:15:56 Z nguyen31hoang08minh2003 Palindrome-Free Numbers (BOI13_numbers) C++14
0 / 100
4 ms 512 KB
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <math.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <map>
#include <ctime>
#define fore(i, a, b) for(ll i = (a), _b = (b); i < (_b); i++)
#define fort(i, a, b) for(ll i = (a), _b = (b); i <= (_b); i++)
#define ford(i, a, b) for(ll i = (a), _b = (b); i >= (_b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;

template<class A,class B> bool mini(A &a,const B b){return a > b ? (a = b, 1) : 0; }
template<class A,class B> bool maxi(A &a,const B b){return a < b ? (a = b, 1) : 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

ll n, a, b, T, dp[25][2][12][12][2],
   vis[25][2][12][12][2];
string t;

ll DP(ll i, bool f, ll x, ll y, bool st) {
    if (i >= n)
        return 1;
    #define v i][f][x][y][st
    if (vis[v] != T) {
        vis[v] = T;
        dp[v] = 0;
        const int d = f ? 9 : (t[i] - '0');
        fort(j, 0, d)
            if (!j) {
                if (st)
                    dp[v] += DP(i + 1, f || (j < d), 10, 10, true);
                else if (x != j && y != j)
                    dp[v] += DP(i + 1, f || (j < d), y, j, false);
            } else {
                if (x != j && y != j)
                    dp[v] += DP(i + 1, f || (j < d), y, j, false);
            }
    }
    return dp[v];
    #undef v
}

ll calc(ll x) {
    stringstream ss;
    ss << x;
    ss >> t;
    ++T;
    n = sz(t);
    return DP(0, false, 10, 10, false);
}

int main() {
    freopen("numbers.INP","r",stdin);
    freopen("numbers.OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b;
    if (!a)
        cout << calc(b) << '\n';
    else
        cout << calc(b) - calc(a - 1) << '\n';
    return 0;
}

Compilation message

numbers.cpp: In function 'int main()':
numbers.cpp:85:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   85 |     freopen("numbers.INP","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
numbers.cpp:86:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   86 |     freopen("numbers.OUT","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Incorrect 3 ms 364 KB Output isn't correct
3 Incorrect 3 ms 512 KB Output isn't correct
4 Incorrect 3 ms 512 KB Output isn't correct
5 Incorrect 2 ms 364 KB Output isn't correct
6 Incorrect 2 ms 364 KB Output isn't correct
7 Incorrect 2 ms 364 KB Output isn't correct
8 Incorrect 2 ms 364 KB Output isn't correct
9 Incorrect 2 ms 364 KB Output isn't correct
10 Incorrect 3 ms 364 KB Output isn't correct
11 Incorrect 2 ms 364 KB Output isn't correct
12 Incorrect 2 ms 364 KB Output isn't correct
13 Incorrect 2 ms 364 KB Output isn't correct
14 Incorrect 3 ms 364 KB Output isn't correct
15 Incorrect 2 ms 364 KB Output isn't correct
16 Incorrect 3 ms 512 KB Output isn't correct
17 Incorrect 2 ms 364 KB Output isn't correct
18 Incorrect 2 ms 504 KB Output isn't correct
19 Incorrect 2 ms 364 KB Output isn't correct
20 Incorrect 2 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Incorrect 3 ms 492 KB Output isn't correct
3 Incorrect 2 ms 364 KB Output isn't correct
4 Incorrect 2 ms 364 KB Output isn't correct
5 Incorrect 2 ms 364 KB Output isn't correct
6 Incorrect 3 ms 364 KB Output isn't correct
7 Incorrect 2 ms 364 KB Output isn't correct
8 Incorrect 3 ms 364 KB Output isn't correct
9 Incorrect 2 ms 364 KB Output isn't correct
10 Incorrect 4 ms 512 KB Output isn't correct
11 Incorrect 3 ms 364 KB Output isn't correct
12 Incorrect 3 ms 364 KB Output isn't correct
13 Incorrect 2 ms 364 KB Output isn't correct
14 Incorrect 3 ms 512 KB Output isn't correct
15 Incorrect 2 ms 364 KB Output isn't correct
16 Incorrect 2 ms 364 KB Output isn't correct
17 Incorrect 2 ms 364 KB Output isn't correct
18 Incorrect 3 ms 512 KB Output isn't correct
19 Incorrect 2 ms 364 KB Output isn't correct
20 Incorrect 2 ms 364 KB Output isn't correct
21 Incorrect 3 ms 364 KB Output isn't correct
22 Incorrect 3 ms 364 KB Output isn't correct
23 Incorrect 2 ms 364 KB Output isn't correct
24 Incorrect 3 ms 364 KB Output isn't correct
25 Incorrect 2 ms 364 KB Output isn't correct
26 Incorrect 2 ms 364 KB Output isn't correct
27 Incorrect 3 ms 364 KB Output isn't correct
28 Incorrect 3 ms 364 KB Output isn't correct
29 Incorrect 2 ms 364 KB Output isn't correct
30 Incorrect 2 ms 364 KB Output isn't correct
31 Incorrect 2 ms 364 KB Output isn't correct
32 Incorrect 2 ms 364 KB Output isn't correct
33 Incorrect 3 ms 364 KB Output isn't correct
34 Incorrect 2 ms 364 KB Output isn't correct
35 Incorrect 3 ms 364 KB Output isn't correct
36 Incorrect 3 ms 364 KB Output isn't correct
37 Incorrect 3 ms 364 KB Output isn't correct
38 Incorrect 2 ms 364 KB Output isn't correct
39 Incorrect 2 ms 364 KB Output isn't correct
40 Incorrect 2 ms 364 KB Output isn't correct
41 Incorrect 2 ms 364 KB Output isn't correct
42 Incorrect 3 ms 364 KB Output isn't correct
43 Incorrect 2 ms 364 KB Output isn't correct
44 Incorrect 2 ms 364 KB Output isn't correct
45 Incorrect 3 ms 364 KB Output isn't correct