제출 #861166

#제출 시각아이디문제언어결과실행 시간메모리
861166ZeroCoolXylophone (JOI18_xylophone)C++14
100 / 100
69 ms1184 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int a[5001]; void solve(int n) { int x, y, i, u, v, mn; a[2] = query(1, 2); for (i = 2; i < n; i++) { x = query(i, i + 1); y = query(i - 1, i + 1); a[i + 1] = a[i] + x * (a[i] - a[i - 1] < 0 ? 1 : -1) * (y == x + abs(a[i] - a[i - 1]) ? -1 : 1); } mn = *min_element(a + 1, a + n + 1); for (i = 1; i <= n; i++) { a[i] -= mn; if (!a[i]) u = i; if (a[i] == n - 1) v = i; } bool flag = u < v; for (int i = 1; i <= n; i++) answer(i, flag ? a[i] + 1 : n - a[i]); }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:19:40: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |     for (int i = 1; i <= n; i++) answer(i, flag ? a[i] + 1 : n - a[i]);
      |                                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xylophone.cpp:19:40: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...