제출 #501795

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

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:24:18: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |   int odg = query(p, p - 1);
      |             ~~~~~^~~~~~~~~~
xylophone.cpp:35:4: warning: 'odg2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |    if (odg2==rj[i-1]-rj[i-2]+odg1){
      |    ^~
xylophone.cpp:59:29: warning: 'odg1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |    if (odg2==rj[i+1]-rj[i+2]+odg1){
      |              ~~~~~~~~~~~~~~~^~~~~
xylophone.cpp:59:4: warning: 'odg2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |    if (odg2==rj[i+1]-rj[i+2]+odg1){
      |    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...