Submission #704719

# Submission time Handle Problem Language Result Execution time Memory
704719 2023-03-02T18:56:57 Z bebra Xylophone (JOI18_xylophone) C++17
0 / 100
0 ms 208 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;


int my_query(int l, int r) {
    return query(l + 1, r + 1);
}


void solve(int n) {
    if (n == 2) {
        answer(1, 1);
        answer(2, 2);
    }

    vector<int> d1(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        d1[i] = my_query(i, i + 1);
    }
    vector<int> d2(n - 2);
    for (int i = 0; i < n - 2; ++i) {
        d2[i] = my_query(i, i + 2);
    }
    vector<int> a(n);
    // relative[i] == 0:
    //      a[i] < a[i + 1]
    // relative[i] == 1:
    //      a[i] > a[i + 1]
    vector<int> relative(n - 1);
    for (int i = 0; i < n - 2; ++i) {
        if (d1[i] + d1[i + 1] == d2[i]) {
            relative[i + 1] = relative[i];
        } else {
            relative[i + 1] = 1 - relative[i];
        }
    }

    for (int i = 0; i < n - 1; ++i) {
        if (relative[i] == 0) {
            a[i + 1] = a[i] + d1[i];
        } else {
            a[i + 1] = a[i] - d1[i];
        }
    }

    int min_pos = 0;
    int max_pos = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < a[min_pos]) {
            min_pos = i;
        }
        if (a[i] > a[max_pos]) {
            max_pos = i;
        }
    }
    if (min_pos > max_pos) {
        for (int i = 0; i < n - 1; ++i) {
            if (relative[i] == 0) {
                a[i + 1] = a[i] - d1[i];
            } else {
                a[i + 1] = a[i] + d1[i];
            }
        }
    }

    int mn = *min_element(a.begin(), a.end());
    if (mn <= 0) {
        for (auto& x : a) {
            x += abs(mn) + 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        answer(i + 1, a[i]);
    }
}


// int main() {
//     int n;
//     cin >> n;

//     solve(n);
// }
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -