Submission #993185

#TimeUsernameProblemLanguageResultExecution timeMemory
993185MrDebooRobots (IOI13_robots)C++17
76 / 100
1948 ms59480 KiB
#include "robots.h" #include "bits/stdc++.h" using namespace std; vector<pair<int,int>>v; void slv(deque<int>dq){ map<pair<int,int>,int>mp; priority_queue<pair<int,int>>pq; int l=0; for(int i=0;i<dq.size();i++){ while(l<v.size()&&dq[i]>v[l].first){ pq.push({v[l].second,v[l].first}); l++; } if(pq.size()){ mp[{pq.top().second,pq.top().first}]++; pq.pop(); } } vector<pair<int,int>>vec; for(auto &i:v){ if(mp[i]){ mp[i]--; }else vec.push_back(i); } v=vec; } int putaway(int A, int B, int t, int x[], int y[], int w[], int s[]) { for(int i=0;i<t;i++)v.push_back({w[i],s[i]}); deque<int>a,b; for(int i=0;i<A;i++)a.push_back(x[i]); for(int i=0;i<B;i++)b.push_back(y[i]); sort(a.begin(),a.end()); sort(b.begin(),b.end()); int sz=t+1,cnt=0; while(v.size()&&sz!=v.size()){ cnt++; sz=v.size(); sort(v.begin(),v.end()); slv(a); for(auto &i:v)swap(i.first,i.second); sort(v.begin(),v.end()); slv(b); for(auto &i:v)swap(i.first,i.second); } if(v.size())cnt=-1; return cnt; }

Compilation message (stderr)

robots.cpp: In function 'void slv(std::deque<int>)':
robots.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<dq.size();i++){
      |                 ~^~~~~~~~~~
robots.cpp:10:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         while(l<v.size()&&dq[i]>v[l].first){
      |               ~^~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:35: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]
   35 |     while(v.size()&&sz!=v.size()){
      |                     ~~^~~~~~~~~~
#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...