# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
469135 | | ala2 | Bob (COCI14_bob) | C++14 | | 506 ms | 24056 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
using namespace std;
int a[1010][1010];
int dpr[1010][1010];
int dpc[1010][1010];
pair<int,int> dp3[1010][1010];
signed main()
{
int n;
cin>>n;
int m;
cin>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cin>>a[i][j];
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
dpc[i][j]=1;
dpr[i][j]=1;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(i>0)
{
if(a[i][j]==a[i-1][j])
{
dpr[i][j]=dpr[i-1][j]+1;
}
}
if(j>0)
{
if(a[i][j]==a[i][j-1])
{
dpc[i][j]=dpc[i][j-1]+1;
}
}
}
}// ff for c ss for r
int ans=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{ //cout<<dpr[i][j]<<" ";
for(int k=j;k>=0;k--)
{
if(a[i][k]!=a[i][k+1]&&k!=j)
break;
ans+=dpr[i][k];
}
// cout<<" :"<<ans<<" ";
}
// cout<<endl;
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |