Submission #469220

#TimeUsernameProblemLanguageResultExecution timeMemory
469220ala2Bob (COCI14_bob)C++14
120 / 120
772 ms18132 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...