제출 #558097

#제출 시각아이디문제언어결과실행 시간메모리
558097groshiXylophone (JOI18_xylophone)C++17
0 / 100
1 ms208 KiB
#include<iostream> #include "xylophone.h" using namespace std; bool bylo[100000]; int jaki[100000]; /*int query(int x,int y) { cout<<x<<" "<<y<<"\n"; int co; cin>>co; return co; } int answer(int x,int y) { cout<<y<<" "; }*/ void solve(int n) { int pocz=1,kon=n+1,sre,ostd; int szukam=n-1; int mam=0; while(pocz<kon) { sre=(pocz+kon)/2; int k=query(sre,n); mam++; if(k==n-1) { ostd=sre; pocz=sre+1; } else{ kon=sre; } } jaki[ostd]=1; bylo[1]=1; for(int i=ostd+1;i<=n;i++) { if(mam==10000-1) { while(true) mam++; } int k=query(i-1,i); mam++; if(jaki[i-1]-k<=0 || bylo[jaki[i-1]-k]==1) jaki[i]=jaki[i-1]+k; else if(jaki[i-1]+k>n || bylo[jaki[i-1]+k]==1) jaki[i]=jaki[i-1]-k; else{ if(mam==10000-1) { while(true) mam++; } int k1=query(ostd,i); mam++; if(k1==jaki[i-1]-1) jaki[i]=jaki[i-1]-k; else jaki[i]=jaki[i-1]+k; } bylo[jaki[i]]=1; } for(int i=ostd-1;i>=1;i--) { if(mam==10000-1) { while(true) mam++; } int k=query(i,i+1); mam++; if(jaki[i+1]-k<=0 || bylo[jaki[i+1]-k]==1) jaki[i]=jaki[i+1]+k; else if(jaki[i+1]+k>n || bylo[jaki[i+1]+k]==1) jaki[i]=jaki[i+1]-k; else{ if(mam==10000-1) { while(true) mam++; } int k1=query(i,ostd); mam++; if(k1==jaki[i+1]-1) jaki[i]=jaki[i+1]-k; else jaki[i]=jaki[i+1]+k; } bylo[jaki[i]]=1; } for(int i=1;i<=n;i++) answer(i,jaki[i]); }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:9: warning: unused variable 'szukam' [-Wunused-variable]
   20 |     int szukam=n-1;
      |         ^~~~~~
xylophone.cpp:36:15: warning: 'ostd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     jaki[ostd]=1;
      |     ~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...