#include<bits/stdc++.h>
typedef long long ll;
#define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
using namespace std;
int main(){
//fastio
int h, w;
cin >> h >> w;
vector<int> val;
vector<vector<int>> a(h, vector<int> (w));
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
cin >> a[i][j];
val.push_back(a[i][j]);
}
}
sort(val.begin(), val.end());
for(int i=0; i<h; i++){
for(int j=0; j<w; j++)
a[i][j] = lower_bound(val.begin(), val.end(), a[i][j])-val.begin();
}
if(h>1) return 0;
ll ans = 0;
int cb = 0;
for(int j=0; j<w; j++){
if(j && a[0][j-1]<a[0][j]) cb++;
else cb = 1;
ans += cb;
}
for(int j=0; j<w; j++){
if(j && a[0][j-1]-1>a[0][j]){
cb++;
ans += cb;
}
else cb = 0;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
16 ms |
1432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |