제출 #623704

#제출 시각아이디문제언어결과실행 시간메모리
623704sword060Gap (APIO16_gap)C++17
83.51 / 100
62 ms2248 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; long long findGap(int q,int x){ if(q==2){ long long l=0,r=1e18; MinMax(l,r,&l,&r); long long xd=l,lol=(r-l+x-2)/(x-1),ans=lol,c1,c2,i; while(i+lol<r){ MinMax(i,i+lol,&c1,&c2); if(c1!=-1)ans=max(ans,c1-xd),xd=c2; i+=lol+1; } MinMax(i,r,&c1,&c2); if(c1!=-1)ans=max(ans,c1-xd); return ans; }else{ vector<long long>a; long long c=0,v=1e18,zz=x; while(zz&&c<=v){ long long l,r; MinMax(c,v,&l,&r); if(l==-1)break; a.push_back(l);if(l!=r)a.push_back(r); c=l+1;v=r-1;zz-=2; } sort(a.begin(),a.end()); long long ret=0; for(int i=0;i<(int)a.size()-1;i++)ret=max(ret,a[i+1]-a[i]); return ret; } return 0; }

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:12: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 |     while(i+lol<r){
      |           ~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...