제출 #401714

#제출 시각아이디문제언어결과실행 시간메모리
401714bonopo로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define pb push_back #define el "\n" #define f first #define s second typedef long long ll; const ll MM=1e5+5, MOD=1e9+7; int A, B, T, x[MM], y[MM], u[MM]; priority_queue<pair<int,int>> pq; struct toy { int wt, sz, idx; } t[10*MM]; bool cmpw(toy a, toy b) { return a.wt<b.wt; } bool cmps(toy a, toy b) { return a.sz<b.sz; } bool check(int sec) { memset(u, 0, sizeof(u)); int ptr=1, hv=0; // take highest weight you can sort(t+1, t+T+1, cmpw); for(int i=1; i<=A; ++i) { while(ptr<=T&&t[ptr].wt<x[i]) { pq.push({t[ptr].sz, ptr++}); } int cnt=sec; while(!pq.empty()&&cnt) { pair<int,int> e=pq.top(); pq.pop(); if(!u[t[e.s].idx]) { u[t[e.s].idx]=1; ++hv; --cnt; } } } sort(t+1, t+T+1, cmps); while(!pq.empty()) pq.pop(); ptr=1; // take highest size you can for(int i=1; i<=B; ++i) { while(ptr<=T&&t[ptr].sz<y[i]) { pq.push({t[ptr].wt, ptr++}); } int cnt=sec; while(!pq.empty()&&cnt) { pair<int,int> e=pq.top(); pq.pop(); if(!u[t[e.s].idx]) { u[t[e.s].idx]=1; ++hv; --cnt; } } } return hv==T; } int putaway(int _a, int _b, int _t, int X[], int Y[], int W[], int S[]) { A=_a; B=_b; T=_t; for(int i=0; i<A; ++i) x[i+1]=X[i]; for(int i=0; i<B; ++i) y[i+1]=Y[i]; for(int i=0; i<T; ++i) t[i+1].wt=W[i]; for(int i=0; i<T; ++i) t[i+1].sz=S[i]; for(int i=0; i<T; ++i) t[i+1].idx=i+1; if(A>0) sort(x+1, x+A+1); if(B>0) sort(y+1, y+B+1); int lo=1, hi=T, mid, ans=-1; while(lo<=hi) { mid=(lo+hi)/2; if(check(mid)) hi=mid-1, ans=mid; else lo=mid+1; } return ans; }

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

robots.cpp: In function 'bool check(int)':
robots.cpp:33:36: warning: operation on 'ptr' may be undefined [-Wsequence-point]
   33 |             pq.push({t[ptr].sz, ptr++}); }
      |                                 ~~~^~
robots.cpp:33:36: warning: operation on 'ptr' may be undefined [-Wsequence-point]
robots.cpp:43:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   43 |     while(!pq.empty()) pq.pop(); ptr=1;
      |     ^~~~~
robots.cpp:43:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   43 |     while(!pq.empty()) pq.pop(); ptr=1;
      |                                  ^~~
robots.cpp:47:36: warning: operation on 'ptr' may be undefined [-Wsequence-point]
   47 |             pq.push({t[ptr].wt, ptr++}); }
      |                                 ~~~^~
robots.cpp:47:36: warning: operation on 'ptr' may be undefined [-Wsequence-point]
/usr/bin/ld: /tmp/ccfvhlH1.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status