답안 #535254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535254 2022-03-09T19:50:23 Z __Variatto Palindrome-Free Numbers (BOI13_numbers) C++17
23.3333 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
ll dp[20][2][10][10];
ll policz(ll x){
    for(int i=1; i<=19; i++)
        for(int a=0; a<=9; a++)
            for(int b=0; b<=9; b++)
                dp[i][0][a][b]=dp[i][1][a][b]=0;
    int x1=x, i=1, a1=-1, a2=-1;
    while(x1){
        int curr=x1%10;
        if(a1!=-1&&a2==-1) a2=curr;
        if(a1==-1) a1=curr;
        x1/=10, i++;
        if(a1!=-1&&a2!=-1) break;
    }
    for(int a=0; a<=9; a++){
        for(int b=0; b<=9; b++){
            if(a==b)
                continue;
            if((a<a2)||(a==a2 && b<=a1))
                dp[2][0][a][b]=1;
            dp[2][1][a][b]=1;
        }
    }
    while(x1){
        int curr=x1%10;
        for(int a=0; a<=9; a++){
            for(int b=0; b<=9; b++){
                for(int c=0; c<=9; c++){
                    if(a==b||b==c||a==c)
                        continue;
                    dp[i][1][a][b]+=dp[i-1][1][b][c];
                    if(a==curr)
                        dp[i][0][a][b]+=dp[i-1][0][b][c];
                    if(a<curr)
                        dp[i][0][a][b]+=dp[i-1][1][b][c];
                }
            }
        }
        x1/=10, i++;
    }
    ll wyn=0;
    for(int a=0; a<=9; a++)
        for(int b=0; b<=9; b++)
            wyn+=dp[i-1][0][a][b];
    return wyn;
}
ll x, y;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>x>>y;
    cout<<policz(y)-policz(x-1)<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Incorrect 0 ms 332 KB Output isn't correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 0 ms 332 KB Output isn't correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Incorrect 1 ms 316 KB Output isn't correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Incorrect 1 ms 332 KB Output isn't correct
19 Incorrect 1 ms 332 KB Output isn't correct
20 Incorrect 1 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Incorrect 1 ms 332 KB Output isn't correct
5 Incorrect 1 ms 332 KB Output isn't correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Incorrect 1 ms 332 KB Output isn't correct
9 Incorrect 1 ms 332 KB Output isn't correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Correct 1 ms 320 KB Output is correct
12 Incorrect 1 ms 332 KB Output isn't correct
13 Incorrect 1 ms 332 KB Output isn't correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Incorrect 1 ms 332 KB Output isn't correct
17 Incorrect 1 ms 332 KB Output isn't correct
18 Correct 1 ms 332 KB Output is correct
19 Incorrect 1 ms 332 KB Output isn't correct
20 Correct 0 ms 332 KB Output is correct
21 Incorrect 1 ms 332 KB Output isn't correct
22 Incorrect 1 ms 332 KB Output isn't correct
23 Incorrect 1 ms 332 KB Output isn't correct
24 Correct 1 ms 332 KB Output is correct
25 Incorrect 1 ms 320 KB Output isn't correct
26 Incorrect 1 ms 332 KB Output isn't correct
27 Incorrect 1 ms 320 KB Output isn't correct
28 Incorrect 1 ms 332 KB Output isn't correct
29 Correct 1 ms 332 KB Output is correct
30 Incorrect 1 ms 332 KB Output isn't correct
31 Incorrect 1 ms 332 KB Output isn't correct
32 Incorrect 1 ms 332 KB Output isn't correct
33 Incorrect 0 ms 332 KB Output isn't correct
34 Incorrect 1 ms 312 KB Output isn't correct
35 Incorrect 1 ms 332 KB Output isn't correct
36 Incorrect 1 ms 332 KB Output isn't correct
37 Incorrect 1 ms 312 KB Output isn't correct
38 Incorrect 1 ms 332 KB Output isn't correct
39 Incorrect 1 ms 332 KB Output isn't correct
40 Incorrect 1 ms 332 KB Output isn't correct
41 Incorrect 1 ms 332 KB Output isn't correct
42 Correct 1 ms 332 KB Output is correct
43 Incorrect 1 ms 332 KB Output isn't correct
44 Incorrect 1 ms 332 KB Output isn't correct
45 Incorrect 1 ms 332 KB Output isn't correct