제출 #505142

#제출 시각아이디문제언어결과실행 시간메모리
505142tengiz05Xylophone (JOI18_xylophone)C++17
0 / 100
0 ms200 KiB
#include "xylophone.h"
#include <bits/stdc++.h>

static int A[5005];

void solve(int n) {
    A[2] = query(1, 2);
    for (int i = 3; i <= n; i++) {
        int x = query(i - 1, i);
        int y = query(i - 2, i);
        
        if (x + abs(A[i - 2] - A[i - 1]) == y) {
            if (A[i - 2] > A[i - 1]) {
                A[i] = A[i - 1] - x;
            } else {
                A[i] = A[i - 1] + x;
            }
        } else {
            if (A[i - 2] > A[i - 1]) {
                A[i] = A[i - 1] + x;
            } else {
                A[i] = A[i - 1] - x;
            }
        }
    }
    
    if (std::min_element(A + 1, A + n + 1) > std::max_element(A + 1, A + n + 1)) {
        for (int i = 1; i <= n; i++) {
            A[i] = -A[i];
        }
    }
    
    int x = *std::min_element(A + 1, A + n + 1);
    for (int i = 1; i <= n; i++) {
        A[i] = A[i] - x + 1;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...