Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<math.h>
- #include<iomanip>
- #include<time.h>
- #include<algorithm>
- #include<vector>
- #include<map>
- #include<queue>
- #include<string>
- #include<set>
- #define Pi 3.14159265358
- #define mod9 %1000000009
- #define INF 1000000000
- #define mod7 %1000000007
- #define LL unsigned long long
- #define time clock()/(double)CLOCKS_PER_SEC
- using namespace std;
- LL n,i,j,m,a[1001][1001],d[1001][1001],h[1001],ans;
- int main(){
- cin>>n>>m;
- for (i=1;i<=n;i++)
- for (j=1;j<=m;j++){
- scanf("%lld",&a[i][j]);
- if (a[i][j]==a[i-1][j]) d[i][j]+=d[i-1][j]+1; else d[i][j]+=1;
- if (a[i][j]==a[i][j-1]) h[j]=h[j-1]+d[i][j];
- else h[j]=d[i][j];
- ans+=h[j];
- }
- printf("%lld",ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement