답안 #967335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967335 2024-04-22T02:25:20 Z Pring Xylophone (JOI18_xylophone) C++17
100 / 100
64 ms 940 KB
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

namespace {
    const int MXN = 5005;
    int a[MXN];
}

void solve(int n) {
    a[1] = 0;
    a[2] = query(1, 2);
    int pre = a[2];
    FOR(i, 3, n + 1) {
        int x = query(i - 2, i), y = query(i - 1, i);
        if (pre + y == x) {
            if (a[i - 2] < a[i - 1]) a[i] = a[i - 1] + y;
            else a[i] = a[i - 1] - y;
        } else {
            if (a[i - 2] < a[i - 1]) a[i] = a[i - 1] - y;
            else a[i] = a[i - 1] + y;
        }
        pre = y;
    }
    int smlid = min_element(a + 1, a + n + 1) - a;
    int bigid = max_element(a + 1, a + n + 1) - a;
    if (smlid > bigid) {
        FOR(i, 1, n + 1) a[i] = -a[i];
    }
    int sml = *min_element(a + 1, a + n + 1);
    FOR(i, 1, n + 1) a[i] += -sml + 1;
    FOR(i, 1, n + 1) answer(i, a[i]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 2 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 1 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 2 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 7 ms 344 KB Output is correct
18 Correct 8 ms 436 KB Output is correct
19 Correct 8 ms 692 KB Output is correct
20 Correct 12 ms 444 KB Output is correct
21 Correct 8 ms 444 KB Output is correct
22 Correct 11 ms 688 KB Output is correct
23 Correct 7 ms 700 KB Output is correct
24 Correct 9 ms 436 KB Output is correct
25 Correct 8 ms 444 KB Output is correct
26 Correct 7 ms 440 KB Output is correct
27 Correct 10 ms 700 KB Output is correct
28 Correct 12 ms 440 KB Output is correct
29 Correct 9 ms 436 KB Output is correct
30 Correct 8 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 2 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 7 ms 344 KB Output is correct
18 Correct 8 ms 436 KB Output is correct
19 Correct 8 ms 692 KB Output is correct
20 Correct 12 ms 444 KB Output is correct
21 Correct 8 ms 444 KB Output is correct
22 Correct 11 ms 688 KB Output is correct
23 Correct 7 ms 700 KB Output is correct
24 Correct 9 ms 436 KB Output is correct
25 Correct 8 ms 444 KB Output is correct
26 Correct 7 ms 440 KB Output is correct
27 Correct 10 ms 700 KB Output is correct
28 Correct 12 ms 440 KB Output is correct
29 Correct 9 ms 436 KB Output is correct
30 Correct 8 ms 456 KB Output is correct
31 Correct 21 ms 436 KB Output is correct
32 Correct 35 ms 440 KB Output is correct
33 Correct 44 ms 672 KB Output is correct
34 Correct 46 ms 704 KB Output is correct
35 Correct 46 ms 680 KB Output is correct
36 Correct 51 ms 436 KB Output is correct
37 Correct 48 ms 932 KB Output is correct
38 Correct 50 ms 688 KB Output is correct
39 Correct 64 ms 676 KB Output is correct
40 Correct 43 ms 940 KB Output is correct
41 Correct 61 ms 440 KB Output is correct
42 Correct 44 ms 440 KB Output is correct
43 Correct 58 ms 680 KB Output is correct
44 Correct 45 ms 440 KB Output is correct
45 Correct 45 ms 436 KB Output is correct
46 Correct 49 ms 444 KB Output is correct
47 Correct 46 ms 444 KB Output is correct
48 Correct 55 ms 676 KB Output is correct
49 Correct 53 ms 684 KB Output is correct
50 Correct 45 ms 440 KB Output is correct
51 Correct 39 ms 436 KB Output is correct
52 Correct 54 ms 440 KB Output is correct
53 Correct 48 ms 680 KB Output is correct
54 Correct 51 ms 436 KB Output is correct
55 Correct 45 ms 444 KB Output is correct
56 Correct 52 ms 680 KB Output is correct
57 Correct 59 ms 440 KB Output is correct
58 Correct 45 ms 680 KB Output is correct
59 Correct 57 ms 444 KB Output is correct
60 Correct 54 ms 684 KB Output is correct