제출 #874425

#제출 시각아이디문제언어결과실행 시간메모리
874425AlphaMale06Xylophone (JOI18_xylophone)C++14
100 / 100
52 ms592 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; void solve(int n){ int a[n+1]={0}; int q1[n-1]; int q2[n-2]; for(int i=0; i<n-1; i++){ q1[i]=query(i+1, i+2); } for(int i=0; i< n-2; i++){ q2[i]=query(i+1, i+3); } a[1]=1; a[2]=1+q1[0]; int mn=1; for(int i=3; i<=n; i++){ int pos1=a[i-1]+q1[i-2]; int pos2=a[i-1]-q1[i-2]; if(q1[i-2]==q2[i-3] || q2[i-3]==abs(a[i-2]-a[i-1])){ if(a[i-1]>a[i-2])a[i]=pos2; else a[i]=pos1; } else{ if(a[i-1]>a[i-2])a[i]=pos1; else a[i]=pos2; } mn=min(mn ,a[i]); } mn--; int psn=0; int ps1=0; int b[n+1]; for(int i=1; i<=n; i++){ a[i]-=mn; if(a[i]==1)ps1=i; if(a[i]==n)psn=i; } if(ps1>=psn){ a[1]=1; a[2]=1-q1[0]; mn=a[2]; for(int i=3; i<=n; i++){ int pos1=a[i-1]+q1[i-2]; int pos2=a[i-1]-q1[i-2]; if(q1[i-2]==q2[i-3] || q2[i-3]==abs(a[i-2]-a[i-1])){ if(a[i-1]>a[i-2])a[i]=pos2; else a[i]=pos1; } else{ if(a[i-1]>a[i-2])a[i]=pos1; else a[i]=pos2; } mn=min(mn ,a[i]); } mn--; for(int i=1; i<=n; i++){ a[i]-=mn; } } for(int i=1; i<=n; i++){ answer(i, a[i]); } }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:34:9: warning: unused variable 'b' [-Wunused-variable]
   34 |     int b[n+1];
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...