답안 #400754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400754 2021-05-08T15:47:30 Z timmyfeng Xylophone (JOI18_xylophone) C++17
0 / 100
4 ms 200 KB
#include <bits/stdc++.h>
using namespace std;

#include "xylophone.h"

void solve(int n) {
    vector<int> ans(n + 1);
    ans[2] = ans[1] + query(1, 2);

    for (int i = 3; i <= n; ++i) {
        int x = query(i - 2, i);
        int y = query(i - 1, i);

        if (ans[i - 2] < ans[i - 1]) {
            if (x == abs(ans[i - 1] - ans[i - 2])) {
                ans[i] = ans[i - 1] - y;
            } else if (x == y) {
                ans[i] = ans[i - 1] - y;
            } else {
                ans[i] = ans[i - 1] + y;
            }
        } else {
            if (x == abs(ans[i - 1] - ans[i - 2])) {
                ans[i] = ans[i - 1] + y;
            } else if (x == y) {
                ans[i] = ans[i - 1] + y;
            } else {
                ans[i] = ans[i - 1] - y;
            }
        }
    }

    int offset = *min_element(ans.begin(), ans.end());
    for (int i = 1; i <= n; ++i) {
        ans[i] -= offset - 1;
    }

    if (find(ans.begin(), ans.end(), 1) > find(ans.begin(), ans.end(), n)) {
        reverse(ans.begin() + 1, ans.end());
    }

    for (int i = 1; i <= n; ++i) {
        answer(i, ans[i]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 2 ms 200 KB Output is correct
5 Incorrect 4 ms 200 KB Wrong Answer [7]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 2 ms 200 KB Output is correct
5 Incorrect 4 ms 200 KB Wrong Answer [7]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 2 ms 200 KB Output is correct
5 Incorrect 4 ms 200 KB Wrong Answer [7]
6 Halted 0 ms 0 KB -