# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
469220 | | ala2 | Bob (COCI14_bob) | C++14 | | 772 ms | 18132 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 <iostream>
#define int long long
using namespace std;
int a[1010][1010];
int dp[1010][1010];
signed main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
dp[i][j]=1;
}
}
for(int i=1;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]==a[i-1][j])
{
dp[i][j]=dp[i-1][j]+1;
}
}
}// cout<<endl;
int ans=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{//cout<<dp[i][j]<<" ";
int mn=1e9;
for(int k=j;k>=0;k--)
{ // cout<<" "<<i<<" "<<j<<" "<<k<<" ";
if(k<j&&a[i][k]!=a[i][k+1])
break;
mn=min(mn,dp[i][k]);
ans+=mn;
// cout<<" "<<1<<endl;
}
// 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... |