제출 #704236

#제출 시각아이디문제언어결과실행 시간메모리
704236Hiennoob123Xylophone (JOI18_xylophone)C++14
100 / 100
97 ms544 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(i-2, i); ll value2 = query(i-1, i); //cout << i << " " << value << " " << value2 << "\n"; if(value==abs(T[i-1]-T[i-2])) { //cout << -2; if(T[i-2]>T[i-1]) T[i] = T[i-1]+value2; else T[i] = T[i-1]-value2; } else { if(T[i-2]>T[i-1]) { //cout << -3; if(abs(T[i-1]-T[i-2])+value2==value) T[i] = T[i-1]-value2; else { T[i] = T[i-1]+value2; } } else { //cout << -1; if(abs(T[i-1]-T[i-2])+value2==value) T[i] = T[i-1]+value2; else { //cout << -5; T[i] = T[i-1]-value2; } } } } 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; i++) T[i] = n-T[i]+1; } //for(int i = 1; i<= n; i++) cout << T[i] << " "; for(int i = 1; i<= n; i++) { answer(i, T[i]); } }

컴파일 시 표준 에러 (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...