Submission #892151

#TimeUsernameProblemLanguageResultExecution timeMemory
892151vjudge1Bob (COCI14_bob)C++17
120 / 120
571 ms10340 KiB
#include<bits/stdc++.h> using namespace std; const int N=1e3+7, inf=1e9+7; int m, n, a[N][N], b[N][N]; long long res=0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>m>>n; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) cin>>a[i][j]; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) b[i][j]=1; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) { if(a[i][j]==a[i-1][j]) b[i][j]=b[i-1][j]+1; } for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) { int tmp=inf; for(int k=j; k>=1; k--) { if(a[i][k]!=a[i][k+1]&&k!=j) break; tmp=min(tmp, b[i][k]); res+=tmp; } } cout<<res; }
#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...