# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526902 | eecs | Sandcastle 2 (JOI22_ho_t5) | C++17 | 13 ms | 868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50010;
int h, w, a[maxn];
long long ans;
int id(int x, int y) {
return (x - 1) * w + y;
}
int main() {
scanf("%d %d", &h, &w);
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
scanf("%d", &a[id(i, j)]);
}
}
if (h == 1) {
static int f[maxn], id[maxn];
fill(f + 1, f + w + 1, 1);
iota(id + 1, id + w + 1, 1);
sort(id + 1, id + w + 1, [&](int x, int y) { return a[x] < a[y]; });
for (int i = 1; i <= w; i++) {
int x = id[i];
if (x > 1 && a[x - 1] < a[x]) f[x] += f[x - 1];
if (x < w && a[x + 1] < a[x]) f[x] += f[x + 1];
}
printf("%lld\n", accumulate(f + 1, f + w + 1, 0LL)), exit(0);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |