Submission #1078436

# Submission time Handle Problem Language Result Execution time Memory
1078436 2024-08-27T17:22:41 Z modwwe Palindrome-Free Numbers (BOI13_numbers) C++17
0 / 100
3 ms 600 KB
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int inf=1e9;
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c,d,e;

};

int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid;
int  i,s10,s12;
int kk;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
fin(task),fou(task);
#endif
    NHP
    /// cin>>s1;
    //modwwe
 phongbeo();
//checktime
}
int dp[18][2][10][10];
vector<int> v;
int calc(int a,bool b,int x,int y)
{
    if(a==v.size()) return 1;
    if(dp[a][b][x][y]!=-1) return dp[a][b][x][y];
    int& s=dp[a][b][x][y];
    s=0;
    int limit=v[a];
    if(b)limit=9;
    if(x==y)
    {
        if(a==v.size()-1&&b) {
                return s=10;}
        else if(a==v.size()-1&&!b) return s=v[a]+1;
        else if(b)
        {
            for(int i=1; i<=9; i++)
                for(int j=0; j<=9; j++)
                {
                    if(i==j) continue;
                    s+=calc(a+2,1,i,j);
                }
                s+=calc(a+1,b,0,0);
        }
        else
        {
            for(int i=v[a]; i>=1; i--)
            {
                int llimit=v[a+1];
                if(i!=v[a])llimit=9,b=1;
                for(int j=0; j<=llimit; j++)
                { if(i==j) continue;
                    if(llimit==j)s+=calc(a+2,b,i,j);
                    else s+=calc(a+2,1,i,j);
                }
            }
            if(v[a]==0)s+=calc(a+1,b,0,0);
            else s+=calc(a+1,1,0,0);
        }
    }
    else
    {
        for(int i=0; i<=limit; i++)
        {
            if(i==x||i==y) continue;
             if(i==limit)s+=calc(a+1,b,y,i);
             else s+=calc(a+1,1,y,i);
        }
    }
    return s;
}
int get(int x)
{
    v.clear();
    while(x!=0)
    {
        v.pb(x%10);
        x/=10;
    }
    reverse(v.begin(),v.end());
memset(dp,-1,sizeof dp);
    return calc(0,0,0,0);
}
void phongbeo()
{
     cin>>l>>r;
     cout<<get(r)-get(l-1);
}

Compilation message

numbers.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main()
      | ^~~~
numbers.cpp: In function 'long long int calc(long long int, bool, long long int, long long int)':
numbers.cpp:64:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     if(a==v.size()) return 1;
      |        ~^~~~~~~~~~
numbers.cpp:72:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         if(a==v.size()-1&&b) {
      |            ~^~~~~~~~~~~~
numbers.cpp:74:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         else if(a==v.size()-1&&!b) return s=v[a]+1;
      |                 ~^~~~~~~~~~~~
numbers.cpp:77:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   77 |             for(int i=1; i<=9; i++)
      |             ^~~
numbers.cpp:83:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   83 |                 s+=calc(a+1,b,0,0);
      |                 ^
numbers.cpp: In function 'int main()':
numbers.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
numbers.cpp:52:1: note: in expansion of macro 'fin'
   52 | fin(task),fou(task);
      | ^~~
numbers.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fou(x) freopen(x".ans","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
numbers.cpp:52:11: note: in expansion of macro 'fou'
   52 | fin(task),fou(task);
      |           ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB Output isn't correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Incorrect 2 ms 348 KB Output isn't correct
5 Incorrect 2 ms 344 KB Output isn't correct
6 Incorrect 2 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Incorrect 2 ms 348 KB Output isn't correct
9 Incorrect 2 ms 348 KB Output isn't correct
10 Incorrect 2 ms 348 KB Output isn't correct
11 Incorrect 3 ms 348 KB Output isn't correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Incorrect 2 ms 348 KB Output isn't correct
14 Incorrect 2 ms 348 KB Output isn't correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Incorrect 2 ms 344 KB Output isn't correct
17 Incorrect 2 ms 344 KB Output isn't correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Incorrect 2 ms 348 KB Output isn't correct
20 Incorrect 2 ms 348 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Incorrect 2 ms 348 KB Output isn't correct
6 Incorrect 2 ms 600 KB Output isn't correct
7 Incorrect 2 ms 348 KB Output isn't correct
8 Incorrect 2 ms 348 KB Output isn't correct
9 Incorrect 1 ms 356 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Incorrect 2 ms 348 KB Output isn't correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Incorrect 2 ms 348 KB Output isn't correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Incorrect 2 ms 348 KB Output isn't correct
16 Incorrect 3 ms 348 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 1 ms 348 KB Output isn't correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Incorrect 2 ms 348 KB Output isn't correct
21 Incorrect 2 ms 524 KB Output isn't correct
22 Incorrect 2 ms 348 KB Output isn't correct
23 Incorrect 2 ms 348 KB Output isn't correct
24 Incorrect 2 ms 348 KB Output isn't correct
25 Incorrect 2 ms 348 KB Output isn't correct
26 Incorrect 2 ms 348 KB Output isn't correct
27 Incorrect 1 ms 348 KB Output isn't correct
28 Incorrect 2 ms 348 KB Output isn't correct
29 Incorrect 2 ms 348 KB Output isn't correct
30 Incorrect 2 ms 344 KB Output isn't correct
31 Incorrect 2 ms 600 KB Output isn't correct
32 Incorrect 2 ms 344 KB Output isn't correct
33 Incorrect 3 ms 348 KB Output isn't correct
34 Incorrect 2 ms 348 KB Output isn't correct
35 Incorrect 2 ms 348 KB Output isn't correct
36 Incorrect 2 ms 348 KB Output isn't correct
37 Incorrect 2 ms 524 KB Output isn't correct
38 Incorrect 2 ms 524 KB Output isn't correct
39 Incorrect 2 ms 344 KB Output isn't correct
40 Incorrect 2 ms 348 KB Output isn't correct
41 Incorrect 1 ms 348 KB Output isn't correct
42 Incorrect 1 ms 348 KB Output isn't correct
43 Incorrect 1 ms 348 KB Output isn't correct
44 Incorrect 2 ms 348 KB Output isn't correct
45 Incorrect 2 ms 348 KB Output isn't correct