제출 #544265

#제출 시각아이디문제언어결과실행 시간메모리
544265krit3379로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 1000005 struct A{ int w,s; bool operator<(const A& o)const{ return s<o.s; } }; bool comw(A a,A b){ return a.w<b.w; } vector<A> p; priority_queue<A> q; int putaway(int a,int b,int t,int x[50005],int y[50005],int w[N],int s[N]){ int i,l,r,mid,now,cnt,ans; sort(x,x+a); sort(y,y+b); for(i=0;i<t;i++){ if(w[i]>=x[a-1]&&s[i]>=y[b-1])return -1; p.push_back({w[i],s[i]}); } sort(p.begin(),p.end(),comw); l=1,r=t; while(l<=r){ mid=(l+r)/2; now=0; for(i=0;i<a;i++){ while(now<t&&p[now].w<x[i])q.push(p[now++]); cnt=mid; while(cnt--&&!q.empty())q.pop(); } while(now<t)q.push(p[now++]); for(i=b-1;i>=0;i--){ cnt=mid; while(cnt--&&!q.empty()&&q.top().s<y[i])q.pop(); } if(q.empty())ans=mid,r=mid-1; else l=mid+1; while(!q.empty())q.pop(); } return ans; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:20:27: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     int i,l,r,mid,now,cnt,ans;
      |                           ^~~
/usr/bin/ld: /tmp/ccWvnRbB.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status