# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
683108 |
2023-01-17T17:17:41 Z |
Ahmed57 |
Bob (COCI14_bob) |
C++14 |
|
405 ms |
17852 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#include <bits/stdc++.h>
using namespace std;
vector<long long> hist(1001,0),col(1001,0);
long long n,m;
long long sum_area = 0;
void getMaxArea(){
stack<long long> s;long long tp;long long i=0;
long long la = 0;
while(i<m){
if(i>0&&col[i]!=col[i-1]){
while(s.empty()==false) {
tp = s.top();
s.pop();
sum_area+=hist[tp]*(s.empty()?i-la:i-s.top()-1);
}
la = i;
}
if(s.empty()||hist[s.top()]<=hist[i])s.push(i++);
else{
tp = s.top();s.pop();
sum_area+=hist[tp]*(s.empty()?i-la:i-s.top()-1);
}
}
while (s.empty() == false) {
tp = s.top();
s.pop();
sum_area+= hist[tp] * (s.empty() ? i-la : i - s.top() - 1);
}
}
signed main(){
cin>>n>>m;
long long arr[n][m];
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++){
cin>>arr[i][j];
}
}
for(int i = 0;i<n;i++){
if(i==0){
for(int j = 0;j<m;j++){col[j]=arr[i][j];hist[j]=1;}
}else{
for(int j = 0;j<m;j++){
col[j] = arr[i][j];
if(arr[i][j]==arr[i-1][j])hist[j]++;
else hist[j] = 1;
}
}
getMaxArea();
}
cout<<sum_area;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
2744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
3204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
3504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
3388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
302 ms |
14760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
376 ms |
17852 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
370 ms |
17588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
405 ms |
17844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |