제출 #502279

#제출 시각아이디문제언어결과실행 시간메모리
502279vrohakXylophone (JOI18_xylophone)C++14
100 / 100
111 ms368 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int n) { int A[n]; A[0] = 0; int D[n - 1]; int T[n - 2]; for(int i = 1; i < n; i++) { D[i - 1] = query(i, i + 1); } for(int i = 2; i < n; i++) { T[i - 2] = query(i - 1, i + 1); } A[1] = D[0]; bool up = true; for(int i = 2; i < n; i++) { if(D[i - 2] + D[i - 1] != T[i - 2]) { up = !up; } A[i] = A[i - 1] + D[i - 1] * ((int)up * 2 - 1); } int rj1[n+1], rj2[n+1]; int mx = 0, mn = 0x3f3f3f3f; int idx1 = 0, idx2 = 0, pt1=query(1, n); for(int i = 0; i < n; i++) { mn = min(mn, A[i]); } mn = (-1)*mn+1; for(int i=0;i<n;i++){ rj1[i] = A[i]+mn; rj2[i] = -A[i]; } mn=0x3f3f3f3f; for(int i = 0; i < n; i++) { mn = min(mn, rj2[i]); } mn = (-1)*mn+1; for(int i=0;i<n;i++) rj2[i]+=mn; for(int i=0;i<n;i++){ if(rj1[i] == 1) idx1 = i; if(rj1[i] == n) idx2 = i; } if(idx1 < idx2) { for(int i = 0; i < n; i++) { answer(i + 1, rj1[i]); } } else { for(int i = 0; i < n; i++) { answer(i + 1, rj2[i]); } } return; }

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:24:6: warning: unused variable 'mx' [-Wunused-variable]
   24 |  int mx = 0, mn = 0x3f3f3f3f;
      |      ^~
xylophone.cpp:25:26: warning: unused variable 'pt1' [-Wunused-variable]
   25 |  int idx1 = 0, idx2 = 0, pt1=query(1, n);
      |                          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...