Submission #1290667

#TimeUsernameProblemLanguageResultExecution timeMemory
1290667gecepanteriXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
int n = N; int dizi[n]; for(int i = 0; i < n - 1; i++){ dizi[i] = query(i, i + 1); } int R[n]; R[0] = 0; R[1] = dizi[0]; for(int i = 1; i < n - 1; i++){ int d_total = query(i - 1, i + 1); int d_prev = dizi[i - 1]; int d_curr = dizi[i]; int direction = R[i] - R[i - 1]; if(d_total == d_prev + d_curr){ if(direction > 0){ R[i + 1] = R[i] + d_curr; } else{ R[i + 1] = R[i] - d_curr; } } else{ if(direction > 0){ R[i + 1] = R[i] - d_curr; } else{ R[i + 1] = R[i] + d_curr; } } } int min_R = R[0]; int max_R = R[0]; int idx_min = 0; int idx_max = 0; for(int i = 1; i < n; i++){ if(R[i] < min_R){ min_R = R[i]; idx_min = i; } if(R[i] > max_R){ max_R = R[i]; idx_max = i; } } if(idx_min < idx_max){ int C = 1 - min_R; for(int i = 0; i < n; i++){ answer(i, R[i] + C); } } else{ for(int i = 0; i < n; i++){ answer(i, max_R - R[i] + 1); } }

Compilation message (stderr)

xylophone.cpp:1:9: error: 'N' was not declared in this scope
    1 | int n = N;
      |         ^
xylophone.cpp:2:14: error: size of array 'dizi' is not an integral constant-expression
    2 |     int dizi[n];
      |              ^
xylophone.cpp:3:5: error: expected unqualified-id before 'for'
    3 |     for(int i = 0; i < n - 1; i++){
      |     ^~~
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
    3 |     for(int i = 0; i < n - 1; i++){
      |                            ^
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:3:20: error: 'i' does not name a type
    3 |     for(int i = 0; i < n - 1; i++){
      |                    ^
xylophone.cpp:3:31: error: 'i' does not name a type
    3 |     for(int i = 0; i < n - 1; i++){
      |                               ^
xylophone.cpp:7:11: error: size of array 'R' is not an integral constant-expression
    7 |     int R[n];
      |           ^
xylophone.cpp:8:5: error: 'R' does not name a type
    8 |     R[0] = 0;
      |     ^
xylophone.cpp:9:5: error: 'R' does not name a type
    9 |     R[1] = dizi[0];
      |     ^
xylophone.cpp:11:5: error: expected unqualified-id before 'for'
   11 |     for(int i = 1; i < n - 1; i++){
      |     ^~~
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
   11 |     for(int i = 1; i < n - 1; i++){
      |                            ^
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:28: error: the value of 'n' is not usable in a constant expression
xylophone.cpp:11:20: error: 'i' does not name a type
   11 |     for(int i = 1; i < n - 1; i++){
      |                    ^
xylophone.cpp:11:31: error: 'i' does not name a type
   11 |     for(int i = 1; i < n - 1; i++){
      |                               ^
xylophone.cpp:40:5: error: expected unqualified-id before 'for'
   40 |     for(int i = 1; i < n; i++){
      |     ^~~
xylophone.cpp:40:20: error: 'i' does not name a type
   40 |     for(int i = 1; i < n; i++){
      |                    ^
xylophone.cpp:40:27: error: 'i' does not name a type
   40 |     for(int i = 1; i < n; i++){
      |                           ^
xylophone.cpp:51:5: error: expected unqualified-id before 'if'
   51 |     if(idx_min < idx_max){
      |     ^~
xylophone.cpp:57:9: error: expected unqualified-id before 'else'
   57 |         else{
      |         ^~~~