제출 #526914

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
5269142022-02-16 16:20:06eecsSandcastle 2 (JOI22_ho_t5)C++17
24 / 100
5054 ms888 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50010;
const int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
int h, w, ans, tim, a[maxn], vis[maxn];
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);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d %d", &h, &w);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |             scanf("%d", &a[id(i, j)]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:49:35: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |                     if (a[id(x, y)] > a[id(_x, _y)] && a[id(_x, _y)] > mx) mx = a[id(_x, _y)], foo = _x, bar = _y;
      |                         ~~~~~~~~~~^
Main.cpp:10:26: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   10 |     return (x - 1) * w + y;
      |                          ^
Main.cpp:34:28: note: 'y' was declared here
   34 |             int mx = 0, x, y;
      |                            ^
#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...