Submission #704227

#TimeUsernameProblemLanguageResultExecution timeMemory
704227Hiennoob123Xylophone (JOI18_xylophone)C++14
0 / 100
1 ms208 KiB
#include "xylophone.h" #include<bits/stdc++.h> #define ll long long #define ld long double #define pll pair<ll,ll> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; const ll maxn = 5005; ll T[maxn]; ll n; ll Min = 1, Max = 2; void solve(int x) { n = x; T[1] = 0; T[2] = query(1,2); ll ptr = 1; ll cur = T[2]; for(int i = 3; i<= n; i++) { ll value = query(min(Min, Max), i); ll value2 = query(max(Min, Max), i); if(value==abs(T[Min]-T[Max])) { if(Min>Max) { T[i] = value2+T[Min]; Max = i; } else { T[i] = T[Max]-value2; Min = i; } } else { if(Min>Max) { T[i] = T[Min]-value2; Min = i; } else { T[i] = T[Max]+value2; Max = i; } } //cout << Min << " " << Max << " " << T[i] << "\n"; } ll Minn = 0; for(int i = 1; i<= n; i++) Minn = min(Minn, T[i]); for(int i = 1; i<= n; i++) T[i] += abs(Minn)+1; ll xMin = 0, xMax = 0; for(int i = 1; i<= n; i++) { if(T[i]==n) xMax = i; if(T[i]==1) xMin = i; } if(xMin>xMax) { for(int i = 1; i<= n/2; i++) swap(T[i], T[n+1-i]); } //for(int i = 1; i<= n; i++) cout << T[i] << " "; for(int i = 1; i<= n; i++) { answer(i, T[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:8: warning: unused variable 'ptr' [-Wunused-variable]
   20 |     ll ptr = 1;
      |        ^~~
xylophone.cpp:21:8: warning: unused variable 'cur' [-Wunused-variable]
   21 |     ll cur = T[2];
      |        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...