답안 #931933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931933 2024-02-22T15:33:03 Z a_l_i_r_e_z_a Xylophone (JOI18_xylophone) C++17
컴파일 오류
0 ms 0 KB
// In the name of God
// Hope is last to die

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
// #define int long long
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

const int maxn = 10000 + 5;
const int inf = 1e9 + 7, mod = 1e9 + 7;
int n, a[maxn], b[maxn];
bool mark[maxn];

void solve(int N){
    n = N;
    for(int i = 1; i <= n - 1; i++) b[i] = query(i, i + 1);
    int l = 1, r = n + 1;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(query(1, mid) == n - 1) r = mid;
        else l = mid;
    }
    int psn = r;
    mark[n] = 1;
    mark[n - b[psn - 1]] = 1;
    a[psn] = n;
    a[psn - 1] = n - b[psn - 1];
    if(psn < n){
        a[psn + 1] = n - b[psn];
        mark[n - b[psn]] = 1;
    }
    for(int i = psn + 2; i <= n; i++){
        if(mark[a[i - 1] + b[i - 1]]){
            a[i] = a[i - 1] - b[i - 1];
            mark[a[i - 1] - b[i - 1]] = 1;
            continue;
        }
        else if(a[i - 1] - b[i - 1] >= 1 && mark[a[i - 1] - b[i - 1]]){
            a[i] = a[i - 1] + b[i - 1];
            mark[a[i - 1] + b[i - 1]] = 1;
            continue;
        }
        int x = query(i - 2, i);
        int mn = min(a[i - 2], a[i - 1]);
        int mx = a[i - 2] + a[i - 1] - mn;
        if(max(mx, a[i - 1] + b[i - 1]) - mn == x){
            a[i] = a[i - 1] + b[i - 1];
            mark[a[i - 1] + b[i - 1]] = 1;
        }
        else{
            a[i] = a[i - 1] - b[i - 1];
            mark[a[i - 1] - b[i - 1]] = 1;
        }
    }
    for(int i = psn - 2; i >= 1; i--){
        if(mark[a[i + 1] + b[i]]){
            a[i] = a[i + 1] - b[i];
            mark[a[i + 1] - b[i]] = 1;
            continue;
        }
        else if(a[i + 1] - b[i] >= 1 && mark[a[i + 1] - b[i]]){
            a[i] = a[i + 1] + b[i];
            mark[a[i + 1] + b[i]] = 1;
            continue;
        }
        int x = query(i, i + 2);
        int mn = min(a[i + 2], a[i + 1]);
        int mx = a[i + 2] + a[i + 1] - mn;
        if(max(mx, a[i + 1] + b[i]) - mn == x){
            a[i] = a[i + 1] + b[i];
            mark[a[i + 1] + b[i]] = 1;
        }
        else{
            a[i] = a[i + 1] - b[i];
            mark[a[i + 1] - b[i]] = 1;
        }
    }
    for(int i = 1; i <= n; i++) answer(i, a[i]);
}

// int32_t main()
// {
//     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//     return 0;
// }

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:29:44: error: 'query' was not declared in this scope
   29 |     for(int i = 1; i <= n - 1; i++) b[i] = query(i, i + 1);
      |                                            ^~~~~
xylophone.cpp:33:12: error: 'query' was not declared in this scope
   33 |         if(query(1, mid) == n - 1) r = mid;
      |            ^~~~~
xylophone.cpp:56:17: error: 'query' was not declared in this scope
   56 |         int x = query(i - 2, i);
      |                 ^~~~~
xylophone.cpp:79:17: error: 'query' was not declared in this scope
   79 |         int x = query(i, i + 2);
      |                 ^~~~~
xylophone.cpp:91:33: error: 'answer' was not declared in this scope
   91 |     for(int i = 1; i <= n; i++) answer(i, a[i]);
      |                                 ^~~~~~