답안 #526902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526902 2022-02-16T15:38:43 Z eecs Sandcastle 2 (JOI22_ho_t5) C++17
9 / 100
13 ms 868 KB
#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

Main.cpp: In function 'int main()':
Main.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d", &h, &w);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf("%d", &a[id(i, j)]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 6 ms 844 KB Output is correct
3 Correct 11 ms 796 KB Output is correct
4 Correct 13 ms 868 KB Output is correct
5 Correct 9 ms 844 KB Output is correct
6 Correct 9 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -