We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
**what's the problem with this submission they mentioned that,
If there are multiple solutions, you can output any one
?**
usingnamespacestd;boolisOk(vector<vector<int>>&v,inti,intj,intl){//checking row and column simultaneouslyfor(inty=0;y<9;y++)if(v[i][y]==l||v[y][j]==l)return0;i=i-i%3;j=j-j%3;//check sub matrix of 3 x 3for(inty=0;y<3;y++)for(intk=0;k<3;k++)if(v[i+y][j+k]==l)return0;return1;}voidf(vector<vector<int>>&v,string&s){if(s=="11")return;inti,j;for(i=0;i<9;i++){intz=0;for(j=0;j<9;j++)if(v[i][j]==0){z=1;break;}if(z)break;}if(i>=9&&j>=9){s="11";return;}for(intl=1;l<=9;l++){if(isOk(v,i,j,l)){v[i][j]=l;f(v,s);// cout<<"** // ";}if(s=="11")return;elsev[i][j]=0;}}//@1****34$1*intmain(){intt;cin>>t;while(t--){vector<vector<int>>v(9,vector<int>(9));for(inti=0;i<9;i++)for(intj=0;j<9;j++)cin>>v[i][j];strings="00";f(v,s);if(s=="00"){cout<<"Lol! ,we regret to inform you that , there is no solution for your input ";return0;}for(inti=0;i<9;i++){for(intj=0;j<9;j++)cout<<v[i][j]<<" ";cout<<"\n";}}}
I have solved the question in java language and it is giving a valid output but it is different from the output in the given test cases. Can anybody figure out the issue with my code?
**what's the problem with this submission they mentioned that,
I have solved the question in java language and it is giving a valid output but it is different from the output in the given test cases. Can anybody figure out the issue with my code?
Input:
My Ouput:
Expected Output:
As you can see although my output is valid but it is different from expected output.
I've passed all the test cases except Test Case 0. It doesn't want to accept any valid solution. So the task is broken, and you should probably avoid it. My rejected solution: 4 5 7 8 9 6 2 1 3 2 6 1 4 5 3 7 8 9 3 8 9 2 7 1 5 6 4 6 9 2 1 4 8 3 5 7 7 4 8 5 3 2 6 9 1 5 1 3 7 6 9 4 2 8 1 3 5 6 8 4 9 7 2 8 7 4 9 2 5 1 3 6 9 2 6 3 1 7 8 4 5
stupid system. wasted all my time
I just got stuck and got the wrong solution after so many attempts but your post helped me. lemon break up spells