Submission #548574

#TimeUsernameProblemLanguageResultExecution timeMemory
548574beaconmcXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" typedef long long ll; using namespace std; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) #define ll int ll twodiff[5001]; ll threediff[5001]; ll max(ll x[5001]){ ll maxi = -1000000000000000; for (auto&i : x){ if (i!=0){ maxi = max(maxi, i); } } return maxi; } ll min(ll x[5001]){ ll mini = 1000000000000000; for (auto&i: x){ if (i!=0){ mini = min(mini, i); } } return mini; } void solve(ll n){ FOR(i,0,5001){ twodiff[i] = 0; threediff[i] = 0; } FOR(i,1,n){ twodiff[i] = query(i, i+1); } FOR(i,1,n-1){ threediff[i] = query(i, i+2); } FOR(i,2,n){ if (threediff[i] != twodiff[i-1] + twodiff[i]){ twodiff[i] *= twodiff[i-1] / abs(twodiff[i-1]); } } if (max(twodiff) - min(twodiff) >=n){ FOR(i,1,n){ twodiff[i] = abs(twodiff[i]); } twodiff[1] *= -1; FOR(i,2,n){ if (threediff[i] != twodiff[i-1] + twodiff[i]){ twodiff[i] *= twodiff[i-1] / abs(twodiff[i-1]); } } ll sus = min(twodiff); FOR(i,1,n){ twodiff[i] -= sus-1; } FOR(i,2,n){ twodiff[i] += twodiff[i-1]; } FOR(i,1,n){ answer(i, twodiff[i]); } }else{ ll sus = min(twodiff); FOR(i,1,n){ twodiff[i] -= sus-1; } FOR(i,2,n){ twodiff[i] += twodiff[i-1]; } FOR(i,1,n){ answer(i, twodiff[i]); } } }

Compilation message (stderr)

xylophone.cpp: In function 'int max(int*)':
xylophone.cpp:16:15: warning: overflow in conversion from 'long int' to 'int' changes value from '-1000000000000000' to '1530494976' [-Woverflow]
   16 |     ll maxi = -1000000000000000;
      |               ^~~~~~~~~~~~~~~~~
xylophone.cpp:17:19: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   17 |     for (auto&i : x){
      |                   ^
      |                   std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from xylophone.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
xylophone.cpp:17:19: error: 'end' was not declared in this scope; did you mean 'std::end'?
   17 |     for (auto&i : x){
      |                   ^
      |                   std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from xylophone.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
xylophone.cpp: In function 'int min(int*)':
xylophone.cpp:26:15: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000' to '-1530494976' [-Woverflow]
   26 |     ll mini = 1000000000000000;
      |               ^~~~~~~~~~~~~~~~
xylophone.cpp:27:18: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   27 |     for (auto&i: x){
      |                  ^
      |                  std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from xylophone.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
xylophone.cpp:27:18: error: 'end' was not declared in this scope; did you mean 'std::end'?
   27 |     for (auto&i: x){
      |                  ^
      |                  std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from xylophone.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~