답안 #318168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
318168 2020-10-31T14:41:24 Z Dymo Palindrome-Free Numbers (BOI13_numbers) C++14
0 / 100
77 ms 131076 KB
#include<bits/stdc++.h>

using namespace std;


#define pb    push_back
#define eb   emplace_back
#define ll  long long
#define pll pair<ll,ll>
#define ff first
#define ss second
//#define endl "\n"
const ll maxn=1e6+50;
const ll mod =998244353 ;
const ll base=3e18;
ll b[100];
ll dp[100][100][100][5][5];
ll dp1[100][100][100][5];

ll cnt1;
ll dem(ll p)
{
   ll cnt=0;
   while (p)
   {
       cnt++;
       p/=10;
   }
   return cnt;
}
ll dem1=0;
ll dosth(ll id,ll nw1,ll nw2,ll h,ll dd)
{


    if (dp[id][nw1][nw2][h][dd]!=-1)
    {
       return dp[id][nw1][nw2][h][dd];
    }
     if (id==cnt1) return dp[id][nw1][nw2][h][dd]=1;
    ll t=0;
    if (dd==0)
    {
        t=t+dosth(id+1,10,10,1,0);
    }
    for (int i=0;i<=9;i++)
    {
        if (dd==0&&i==0) continue;
        if (!h&&b[id+1]<i) continue;
        if (i==nw1||i==nw2) continue;
        t=t+dosth(id+1,nw2,i,h|(b[id+1]>i),1);
    }
    return dp[id][nw1][nw2][h][dd]=t;


}
ll cntpp(ll a)
{
    if (a<0) return 0;

    cnt1 =dem(a);
    ll h= cnt1;
    memset(dp,-1,sizeof(dp));
    while (a)
    {
        b[h]=(a%10);
        a/=10;
        h--;
    }

    /*for (int i=1;i<=cnt1;i++)
    {
        cout <<b[i]<<endl;
    }*/
    return dosth(0,10,10,0,0);

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*if (fopen("p.inp", "r"))
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }*/
    ll a, b;
    cin>> a>> b;
     cout <<cntpp(b)-cntpp(a-1);
    //  cout <<cntpp(a)<<endl;





}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 63 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 67 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 64 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 67 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 73 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 77 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 64 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 63 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 72 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 67 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 65 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 65 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 67 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 65 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 72 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 63 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 66 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 67 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 71 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 67 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 67 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Runtime error 70 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 68 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 69 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
44 Runtime error 62 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
45 Runtime error 68 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)