Submission #863859

#TimeUsernameProblemLanguageResultExecution timeMemory
863859prairie2022Sandcastle 2 (JOI22_ho_t5)C++17
0 / 100
16 ms1432 KiB
#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 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...