Submission #17431

# Submission time Handle Problem Language Result Execution time Memory
17431 2015-12-11T07:07:44 Z choyi0521 Bob (COCI14_bob) C++
0 / 120
556 ms 9536 KB
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX_N=1000;
int n,m,a[MAX_N][MAX_N],h[MAX_N][MAX_N+1];
long long int ans;
int main(){
	cin >> n >> m;
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			cin >> a[i][j];
	fill(h[0],h[0]+m,1);
	for(int i=1; i<n; i++)
		for(int j=0; j<m; j++)
			h[i][j]=(a[i][j]==a[i-1][j])*h[i-1][j]+1;
	int st1[MAX_N],st2[MAX_N];
	for(int i=0; i<n; i++){
		for(int j=0,top=0; j<=n; j++){
			while(top&&(st1[top-1]>h[i][j]||a[i][st2[top-1]]!=a[i][j]))
				ans+=st1[--top]*(j-st2[top]);
			st1[top]=h[i][j];
			st2[top++]=j;
		}
	}
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 9536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 9536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 9536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 9536 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 427 ms 9536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 419 ms 9536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 556 ms 9536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 478 ms 9536 KB Output isn't correct
2 Halted 0 ms 0 KB -