Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

WHY my solution is giving wa for DIGJUMP where ive tried all the test cases

$
0
0

please help i am fed up please can you provide a test casee`

include<iostream>

include<cstdio>

include<map>

using namespace std; int mat[10][10]; map<int,int>m; void update(int a){ //cout<<"yes"<<a; int="" i;="" for(i="0;i&lt;10;i++)" {="" if(m[i]="">mat[i][a]+m[a]+1) { m[i]=1+mat[i][a]+m[a]; update(i); } } } int main(){ for(int o=0;o<10;o++) for(int p=0;p<10;p++) mat[o][p]=30; char ch; ch=getchar();

int i;
for(int i=0;i<=9;i++)
m[i]=40;
int current=0;
int a=ch-48;
m[a]=1;
ch=getchar();
i=0;
int arr[100000];
arr[i]=a;
i++;
while(ch!='\n'){
                int a=ch-48;
                if(i>2)
                if(arr[i-1]==a&&arr[i-2]==a)
                goto A;
                else
                arr[i]=a;
                else
                arr[i]=a;
                current++;
                if(m[a]<=current){
                current=m[a];
                update(a);
                }
                else
                m[a]=current+1;
                for(int j=1;j<40&&i-j>-1;j++)
                {
                        if(mat[arr[i-j]][a]>j)
                        {
                                              mat[arr[i-j]][a]=j;
                                              mat[a][arr[i-j]]=j;
                        }
                        if(m[arr[i-j]]>(1+current+j))
                        {
                                                     m[arr[i-j]]=(current+j+1);
   //                                                  cout<<"A"<<a<<"IJ"<<i-j;
                                                     update(arr[i-j]);
                        }
                }i++;
                A:;
                ch=getchar();

                }
printf("%d\n",current);

cin.get();

}

//01982872437567701452 //112233445566778899 //11223344556677- //988991211223364779911223365482223489-3 //1155334411335533774477226688-11 //99887766446688776655334455697755887554-5 //099887766554433223300885577-5 //016273849567165299885-5 // `


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>