Hey folks , here you can find the video editorial of
CHFDORA
Thank you guys for watching and keep coding.
CodeNCdode
Hey folks , here you can find the video editorial of
CHFDORA
Thank you guys for watching and keep coding.
CodeNCdode
thank man it helps a lot
You can refer to the detailed solution of DYNAMO here Looking forward to your valuable feedback
I have uploaded solution of that as well and for ENGLISH as well
pick each element and find whether the left and right element (of current element ) is same and whether the upper and bottom element (of current element ) is same , if yes then increment count else return.
lli totalpali(vector<vector<int>> &a,lli n,lli m,lli i,lli j){ // i and j are current index
lli rowu = i-1; //rowup
lli rowd = i+1; //rowdown
lli coll = j-1; //col left
lli colr = j+1; // col right
lli cnt=0;
while((rowu>=0 && rowd<n && a[rowu][j]==a[rowd][j]) && (coll>=0 && colr<m && a[i][coll]==a[i][colr])){
cnt++;
rowu--;
rowd++;
coll--;
colr++;
}
return cnt;
}
You’re welcome brother.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,i,j,l,h,p,q;
cin>>t;
while(t–)
{
int n,m,res;
cin>>n>>m;
long long int a[n][m];
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cin>>a[i][j];
}
}
res=n*m;
for(i=1;i<n-1;i++)
{
for(j=1;j<m-1;j++)
{
l=i-1;h=i+1;
p=j-1;q=j+1;
while(l>=0&&h<n&&a[i][p]==a[i][q]&&p>=0&&q<n&&a[l][j]==a[h][j])
{
res++;
l–;h++;
p–;q++;
}
}
}
cout<<res<<endl;
}
}
Is it wrong?
submit and check
silly mistake:- written q<n instead of q<m
i know these kinds of mistakes frustrate a lot , i can feel your pain
exactly what i needed
can we use manacher algorithm to solve this question . i used manacher algo and i got TLE.
My solution : CodeChef: Practical coding for everyone
thanks man for your appreciation
Good
Yes, Manacher’s algorithm can be used.
I have solved it with this algorithm myself and got AC.
My solution:
https://www.codechef.com/viewsolution/28924106
Just applied it on each row and saved the results for all elements.
After that applied it on each column and then added the minimum of the both traversal to the answer.
Thanks man , thanks for the support.