답안 #857526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857526 2023-10-06T10:45:14 Z Trisanu_Das Xylophone (JOI18_xylophone) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#include "xylophone.h"

int a[5001];

void solve(int n){
  a[2] = query(1, 2);
  for(int i = 2; i < n; i++){
    int x = query(i, i + 1), y = query(i - 1, i + 1);
    a[i + 1] = a[i] + x * (a[i] - a[i - 1] < 0 ? 1 : -1) * ((y == x) + abs(a[i] - a[i - 1]) ? 1 : -1);
  }
  int mn = *min_element(a + 1, a + n + 1);
  int u, v;
  for(int i = 1; i < n + 1; i++){
    a[i] -= mn;
    if(a[i] == 0) l = i;
    if(a[i] == n - 1) r = i;
  }
  for(int i = 1; i <= n; i++) answer(i, (l < r) ? a[i] + 1 : n - a[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:17:19: error: 'l' was not declared in this scope
   17 |     if(a[i] == 0) l = i;
      |                   ^
xylophone.cpp:18:23: error: 'r' was not declared in this scope
   18 |     if(a[i] == n - 1) r = i;
      |                       ^
xylophone.cpp:20:42: error: 'l' was not declared in this scope
   20 |   for(int i = 1; i <= n; i++) answer(i, (l < r) ? a[i] + 1 : n - a[i]);
      |                                          ^
xylophone.cpp:20:46: error: 'r' was not declared in this scope
   20 |   for(int i = 1; i <= n; i++) answer(i, (l < r) ? a[i] + 1 : n - a[i]);
      |                                              ^
xylophone.cpp:14:7: warning: unused variable 'u' [-Wunused-variable]
   14 |   int u, v;
      |       ^
xylophone.cpp:14:10: warning: unused variable 'v' [-Wunused-variable]
   14 |   int u, v;
      |          ^