답안 #951251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951251 2024-03-21T13:46:45 Z quanlt206 Xylophone (JOI18_xylophone) C++17
컴파일 오류
0 ms 0 KB
#include "xylophone.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 5007;

int n, b[N], a[N];

int cntQuery = 0;

void answer(int i, int a) {
    cout<<i<<" "<<a<<"\n";
}

int qr[N];

void solve(int m) {
    n = m;
    FOR(i, 1, n) a[i] = 0, qr[i] = 0;
    int pos_1 = 0;
    int d = 1, c = n, g;
    while (d <= c) {
        g = (d + c) >> 1;
        if (query(g, n) == n - 1) pos_1 = g, d = g + 1; else c = g - 1;
    }
    a[pos_1] = 1;
    if (pos_1 > 1) {
        a[pos_1 - 1] = query(pos_1 - 1, pos_1) + 1;
        int last_value = a[pos_1 - 1] - 1;
        int i = pos_1 - 1, mask = 0, top = pos_1; // mask = 0 : tang, 1 : giam
        while (i > 1) {
            int cur_value = query(i - 1, top);
            if (cur_value > last_value) {
                last_value = cur_value;
                if (mask == 0) a[i - 1] = a[top] + cur_value; else a[i - 1] = a[top] - cur_value;
                i--;
                continue;
            }
            if (mask == 0) {
                // dang la day tang dan
                cur_value = query(i - 1, i);
                last_value = cur_value;
                top = i;
                a[i - 1] = a[top] - cur_value;
                mask = 1;
            }
            else {
                cur_value = query(i - 1, i);
                last_value = cur_value;
                top = i;
                a[i - 1] = a[top] + cur_value;
                mask = 0;
            }
            i--;
        }
    }
    if (pos_1 < n) {
        a[pos_1 + 1] = query(pos_1, pos_1 + 1) + 1;
        int last_value = a[pos_1 + 1] - 1;
        int i = pos_1 + 1, mask = 0, top = pos_1;
        while (i < n) {
            int cur_value = query(top, i + 1);
            if (cur_value > last_value) {
                last_value = cur_value;
                if (mask == 0) a[i + 1] = a[top] + cur_value; else a[i + 1] = a[top] - cur_value;
                i++;
                continue;
            }
            if (mask == 0) {
                // dang la day tang dan
                cur_value = query(i, i + 1);
                last_value = cur_value;
                top = i;
                a[i + 1] = a[top] - cur_value;
                mask = 1;
            }
            else {
                cur_value = query(i, i + 1);
                last_value = cur_value;
                top = i;
                a[i + 1] = a[top] + cur_value;
                mask = 0;
            }
            i++;
        }
    }
    FOR(i, 1, n) answer(i, a[i]);
}

Compilation message

/usr/bin/ld: /tmp/ccaTi2AN.o: in function `answer(int, int)':
grader.cpp:(.text+0xa0): multiple definition of `answer(int, int)'; /tmp/ccpN8weN.o:xylophone.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status