Submission #996201

#TimeUsernameProblemLanguageResultExecution timeMemory
996201reginoxXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "xylophone.h" #define ll long long #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> using namespace std; int a[5005], n; int p1[5005], p2[5005]; void thu(int d){ a[2] = d; for(int i = 3; i <= n; i++){ if(a[i-1] > 0){ if(p1[i] == p2[i] || p2[i] == abs(a[i-1])) a[i] = -p1[i]; else a[i] = p1[i]; } else{ if(p1[i] == p2[i] || p2[i] == abs(a[i-1])) a[i] = p1[i]; else a[i] = -p1[i]; } } for(int i = 2; i <= n; i++) a[i] += a[i-1]; int d = *min_element(a+1, a+n+1); for(int i = 1; i <= n; i++){ a[i] += 1-d; } return *max_element(a+1, a+n+1) <= n; } void solve(int m){ n = m; int d = query(1, 2); for(int i = 3; i <= n; i++){ p1[i] = query(i-1, i), p2[i] = query(i-2, i); } for(int tp = -d; tp <= d; tp+=2*d){ if(thu(tp)){ for(int i = 1; i <= n; i++) answer(i, a[i]); return ; } } }

Compilation message (stderr)

xylophone.cpp: In function 'void thu(int)':
xylophone.cpp:24:9: error: declaration of 'int d' shadows a parameter
   24 |     int d = *min_element(a+1, a+n+1);
      |         ^
xylophone.cpp:11:14: note: 'int d' previously declared here
   11 | void thu(int d){
      |          ~~~~^
xylophone.cpp:28:37: error: return-statement with a value, in function returning 'void' [-fpermissive]
   28 |     return *max_element(a+1, a+n+1) <= n;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:38:15: error: could not convert 'thu(tp)' from 'void' to 'bool'
   38 |         if(thu(tp)){
      |            ~~~^~~~
      |               |
      |               void