답안 #860882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860882 2023-10-14T17:41:06 Z EntityPlantt Xylophone (JOI18_xylophone) C++14
11 / 100
5 ms 440 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int a[500];
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]);
}

Compilation message

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]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Runtime error 4 ms 440 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Runtime error 4 ms 440 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -