제출 #501781

#제출 시각아이디문제언어결과실행 시간메모리
501781lovrotXylophone (JOI18_xylophone)C++11
0 / 100
1 ms200 KiB
#include <bits/stdc++.h> using namespace std; int rj[10000]; void solve (int n){ int p; for (int i=n;i>0;i--){ cout<<"query("<<1<<", "<<i<<")"<<endl; int odg; cin>>odg; if (odg<n-1){ rj[i+1]=n; p=i+1; break; } } if (n!=p){ cout<<"query("<<p<<", "<<p+1<<")"<<endl; int odg; cin>>odg; rj[p+1]=n-odg; } if (1!=p){ cout<<"query("<<p<<", "<<p-1<<")"<<endl; int odg; cin>>odg; rj[p-1]=n-odg; } for (int i=p+2;i<n+1;i++){ cout<<"query("<<i-1<<", "<<i<<")"<<endl; int odg1; cin>>odg1; cout<<"query("<<i-2<<", "<<i<<")"<<endl; int odg2; cin>>odg2; if (rj[i-1]>rj[i-2]){ if (odg2==rj[i-1]-rj[i-2]+odg1){ rj[i]=rj[i-1]+odg1; } else { rj[i]=rj[i-1]-odg1; } } else { if (odg2==rj[i-2]-rj[i-1]+odg1){ rj[i]=rj[i-1]-odg1; } else { rj[i]=rj[i-1]+odg1; } } } for (int i=p-2;i>0;i--){ cout<<"query("<<i+1<<", "<<i<<")"<<endl; int odg1; cin>>odg1; cout<<"query("<<i+2<<", "<<i<<")"<<endl; int odg2; cin>>odg2; if (rj[i+1]>rj[i+2]){ if (odg2==rj[i+1]-rj[i+2]+odg1){ rj[i]=rj[i+1]+odg1; } else { rj[i]=rj[i+1]-odg1; } } else { if (odg2==rj[i+2]-rj[i+1]+odg1){ rj[i]=rj[i+1]-odg1; } else { rj[i]=rj[i+1]+odg1; } } } for (int i=1;i<n+1;i++){ cout<<rj[i]<<" "; } return; }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:22: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |   cout<<"query("<<p<<", "<<p+1<<")"<<endl;
      |                      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...