답안 #362280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362280 2021-02-02T14:03:33 Z Hehehe Palindrome-Free Numbers (BOI13_numbers) C++14
0 / 100
4 ms 768 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, dp[30][30][30][2][2];

int get(string s1, string s2){

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

    //cout << s1 << '\n';
    //cout << s2 << '\n';

    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';

        cout << "pos = " << i << '\n';

        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;

                                if(dp[i - 1][A][B][smaller][bigger])cout << A << ' ' << B << ' ' << C << '\n';


                                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);

    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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Incorrect 3 ms 620 KB Output isn't correct
4 Incorrect 2 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 Incorrect 1 ms 364 KB Output isn't correct
10 Incorrect 1 ms 364 KB Output isn't correct
11 Incorrect 1 ms 364 KB Output isn't correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Incorrect 1 ms 364 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 Incorrect 1 ms 364 KB Output isn't correct
17 Incorrect 1 ms 440 KB Output isn't correct
18 Incorrect 1 ms 364 KB Output isn't correct
19 Incorrect 2 ms 620 KB Output isn't correct
20 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Incorrect 3 ms 620 KB Output isn't correct
3 Incorrect 3 ms 620 KB Output isn't correct
4 Incorrect 3 ms 620 KB Output isn't correct
5 Incorrect 2 ms 620 KB Output isn't correct
6 Incorrect 2 ms 492 KB Output isn't correct
7 Incorrect 2 ms 492 KB Output isn't correct
8 Incorrect 2 ms 492 KB Output isn't correct
9 Incorrect 2 ms 492 KB Output isn't correct
10 Incorrect 2 ms 492 KB Output isn't correct
11 Incorrect 2 ms 544 KB Output isn't correct
12 Incorrect 2 ms 492 KB Output isn't correct
13 Incorrect 2 ms 492 KB Output isn't correct
14 Incorrect 2 ms 492 KB Output isn't correct
15 Incorrect 2 ms 492 KB Output isn't correct
16 Incorrect 3 ms 620 KB Output isn't correct
17 Incorrect 1 ms 640 KB Output isn't correct
18 Incorrect 1 ms 620 KB Output isn't correct
19 Incorrect 1 ms 768 KB Output isn't correct
20 Incorrect 1 ms 620 KB Output isn't correct
21 Incorrect 3 ms 620 KB Output isn't correct
22 Incorrect 1 ms 492 KB Output isn't correct
23 Incorrect 3 ms 620 KB Output isn't correct
24 Incorrect 1 ms 620 KB Output isn't correct
25 Incorrect 4 ms 620 KB Output isn't correct
26 Incorrect 3 ms 620 KB Output isn't correct
27 Incorrect 3 ms 620 KB Output isn't correct
28 Incorrect 3 ms 620 KB Output isn't correct
29 Incorrect 1 ms 620 KB Output isn't correct
30 Incorrect 2 ms 620 KB Output isn't correct
31 Incorrect 3 ms 620 KB Output isn't correct
32 Incorrect 1 ms 620 KB Output isn't correct
33 Incorrect 3 ms 620 KB Output isn't correct
34 Incorrect 1 ms 620 KB Output isn't correct
35 Incorrect 4 ms 620 KB Output isn't correct
36 Incorrect 3 ms 620 KB Output isn't correct
37 Incorrect 3 ms 620 KB Output isn't correct
38 Incorrect 3 ms 620 KB Output isn't correct
39 Incorrect 3 ms 620 KB Output isn't correct
40 Incorrect 1 ms 620 KB Output isn't correct
41 Incorrect 3 ms 620 KB Output isn't correct
42 Incorrect 2 ms 620 KB Output isn't correct
43 Incorrect 4 ms 656 KB Output isn't correct
44 Incorrect 3 ms 620 KB Output isn't correct
45 Incorrect 3 ms 620 KB Output isn't correct