Submission #362055

# Submission time Handle Problem Language Result Execution time Memory
362055 2021-02-01T16:17:48 Z Hehehe Palindrome-Free Numbers (BOI13_numbers) C++14
72.5 / 100
1 ms 620 KB
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
#define int long long
/*
#define cin in
#define cout out

ifstream in(".in");
ofstream out(".out");

*/
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

const LL inf = 2e9;
const LL mod = 1e9 + 7;
const int N = 2e2 + 11;
const LL INF64 = 3e18 + 1;
const double eps = 1e-14;
const double PI = acos(-1);

int n, a[N], dp[30][30][30][2][2], M, d;

int get(string s1, string s2, int M, int d){

    n = sz(s1);
    while(sz(s1) < sz(s2))s1 = '0' + s1;
    s1 = '.' + s1;
    s2 = '.' + s2;

    dp[0][0][0][0][0] = 1;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        int x = s1[i] - '0', y = s2[i] - '0';

        for(int smaller = 0; smaller <= 1; smaller++){
            for(int bigger = 0; bigger <= 1; bigger++){

                    for(int A = 0; A <= 9; A++){
                        for(int B = 0; B <= 9; B++){
                            for(int C = 0; C <= 9; C++){

                                if(!smaller && C > y)continue;
                                if(!bigger && C < x)continue;

                                if((i >= 3) && ((C == B) || (A == C) || (B == C)))continue;
                                if((i >= 2) && (B == C))continue;


                                int smaller1 = smaller, bigger1 = bigger;
                                if(C < y)smaller1 = 1;
                                if(C > x)bigger1 = 1;

                                dp[i][B][C][smaller1][bigger1] += dp[i - 1][A][B][smaller][bigger];
                            }
                        }
                    }
            }
        }
    }

    for(int A = 0; A <= 9; A++){
        for(int B = 0; B <= 9; B++){
            for(int smaller = 0; smaller <= 1; smaller++){
                for(int bigger = 0; bigger <= 1; bigger++){
                        ans += dp[n][A][B][smaller][bigger];
                }
            }
        }
    }

    return ans;
}

void solve(){

    string s1, s2;
    cin >> s1 >> s2;

    int ans = get(s1, s2, M, d);

    cout << ans << '\n';

}

int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //cout << setptecision(6) << fixed;

    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Incorrect 1 ms 404 KB Output isn't correct
3 Correct 1 ms 492 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Incorrect 1 ms 364 KB Output isn't correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Incorrect 1 ms 364 KB Output isn't correct
15 Incorrect 1 ms 364 KB Output isn't correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Correct 1 ms 492 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Incorrect 1 ms 364 KB Output isn't correct
11 Correct 1 ms 492 KB Output is correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Incorrect 1 ms 384 KB Output isn't correct
14 Incorrect 1 ms 364 KB Output isn't correct
15 Incorrect 1 ms 364 KB Output isn't correct
16 Correct 1 ms 620 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 1 ms 620 KB Output is correct
19 Correct 1 ms 620 KB Output is correct
20 Correct 1 ms 620 KB Output is correct
21 Correct 1 ms 620 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 620 KB Output is correct
24 Correct 1 ms 620 KB Output is correct
25 Correct 1 ms 620 KB Output is correct
26 Correct 1 ms 620 KB Output is correct
27 Correct 1 ms 620 KB Output is correct
28 Correct 1 ms 620 KB Output is correct
29 Correct 1 ms 620 KB Output is correct
30 Correct 1 ms 620 KB Output is correct
31 Correct 1 ms 620 KB Output is correct
32 Correct 1 ms 620 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 620 KB Output is correct
35 Correct 1 ms 620 KB Output is correct
36 Correct 1 ms 620 KB Output is correct
37 Correct 1 ms 492 KB Output is correct
38 Correct 1 ms 620 KB Output is correct
39 Correct 1 ms 620 KB Output is correct
40 Correct 1 ms 620 KB Output is correct
41 Correct 1 ms 620 KB Output is correct
42 Correct 1 ms 620 KB Output is correct
43 Correct 1 ms 620 KB Output is correct
44 Correct 1 ms 620 KB Output is correct
45 Correct 1 ms 620 KB Output is correct