Submission #1035809

#TimeUsernameProblemLanguageResultExecution timeMemory
1035809andrei_iorgulescuRobots (IOI13_robots)C++14
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; vector<int> x,y; vector<pair<int,int>> robots; bool cmp(pair<int,int> A, pair<int,int> B) { return A.second < B.second; } bool pot(int k) { vector<bool> luat(robots.size()); set<pair<int,int>> s;///y si indexul int i1 = 0; for (int i = 0; i < x.size(); i++) { while (i1 < robots.size() and robots[i1].first < x[i]) { s.insert({robots[i1].second,i1}); i1++; } int ct = k; while (!s.empty() and ct > 0) { ct--; pair<int,int> idk = *s.rbegin(); s.erase(idk); luat[idk.second] = true; } } s.clear(); vector<pair<int,int>> r; for (int i = 0; i < robots.size(); i++) if (!luat[i]) r.push_back(robots[i]); sort(r.begin(),r.end(),cmp); i1 = 0; for (int i = 0; i < y.size(); i++) { while (i1 < r.size() and r[i1].second < y[i]) { s.insert({r[i1].first,i1}); i1++; } int ct = k; while (!s.empty() and ct > 0) { ct--; pair<int,int> idk = *s.rbegin(); s.erase(idk); } } if (s.empty()) return true; return false; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for (int i = 0; i < A; i++) x.push_back(X[i]); for (int i = 0; i < B; i++) y.push_back(Y[i]); sort(x.begin(),x.end()); sort(y.begin(),y.end()); for (int i = 0; i < T; i++) robots.push_back({W[i],S[i]}); for (auto it : robots) if ((A == 0 or it.first >= x[A - 1]) and (B == 0 or it.second >= y[B - 1])) return -1; int st = 0,pas = 1 << 19; while (pas != 0) { if (!pot(st + pas)) st += pas; pas /= 2; } return st + 1; }

Compilation message (stderr)

robots.cpp: In function 'bool pot(int)':
robots.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < x.size(); i++)
      |                     ~~^~~~~~~~~~
robots.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         while (i1 < robots.size() and robots[i1].first < x[i])
      |                ~~~^~~~~~~~~~~~~~~
robots.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < robots.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
robots.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i < y.size(); i++)
      |                     ~~^~~~~~~~~~
robots.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         while (i1 < r.size() and r[i1].second < y[i])
      |                ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...