Submission #502986

#TimeUsernameProblemLanguageResultExecution timeMemory
502986kevinRobots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define nl cout<<"\n" #define s second #define f first #define all(x) x.begin(), x.end() #define ca(v) for(auto i:v) cout<<i<<" "; bool solve(int m, vector<int> &X, vector<int> &Y, vector<pair<int, int>> &T){ set<pair<int, int>> st; for(int i:X) st.insert({i, m}); vector<pair<int, int>> P1; vector<pair<int, int>> P2; for(auto p:T) P1.push_back(p); sort(all(P1)); while(P1.size()){ auto c = P1.back(); P1.pop_back(); auto it = st.upper_bound({c.s, m+1}); if(it != st.end()){ auto nxt = *it; st.erase(it); nxt.s--; if(nxt.s) st.insert(nxt); } else{ P2.push_back({c.s, c.f}); } } sort(all(P2)); st.clear(); for(int i:Y) st.insert({i, m}); while(P2.size()){ auto c = P2.back(); P2.pop_back(); auto it = st.upper_bound({c.s, m+1}); if(it != st.end()){ auto nxt = *it; st.erase(it); nxt.s--; if(nxt.s) st.insert(nxt); } else{ return false; } } return true; } int putaway(int A, int B, int N, vector<int> X, vector<int> Y, vector<int> W, vector<int> S){ sort(all(X)); sort(all(Y)); int ans = N+1; int l = 1; int r = N; vector<pair<int, int>> T; for(int i=0; i<N; i++) T.push_back({S[i], W[i]}); while(l <= r){ int m = (l + r) / 2; if(solve(m, X, Y, T)){ ans = m; r = m-1; } else l = m+1; } if(ans == N+1) return -1; return ans; } // int main() // { // ios_base::sync_with_stdio(0); cin.tie(0); // if (fopen("input.in", "r")) freopen("input.in", "r", stdin); // int A, B, T; // cin>>A>>B>>T; // vector<int> X(A); // vector<int> Y(B); // vector<int> W(T); // vector<int> S(T); // for(int i=0; i<A; i++) cin>>X[i]; // for(int i=0; i<B; i++) cin>>Y[i]; // for(int i=0; i<T; i++) cin>>W[i]>>S[i]; // cout<<putaway(A, B, T, X, Y, W, S); // }

Compilation message (stderr)

/usr/bin/ld: /tmp/cc1tpA59.o: in function `main':
grader.c:(.text.startup+0x1b1): undefined reference to `putaway'
collect2: error: ld returned 1 exit status