Submission #404702

#TimeUsernameProblemLanguageResultExecution timeMemory
404702ly20Robots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123456; //x -> w //y -> s int x[MAXN], y[MAXN], w[MAXN], s[MAXN]; int va[MAXN], vb[MAXN]; int n, a, b; int marc[MAXN]; bool cmp1(int a, int b) { return w[a] < w[b]; } bool cmp2(int a, int b) { return s[a] < s[b]; } bool teste(int t) { priority_queue < pair <int, int> > s; int ts = 0; int cur = 0; for(int i = 0; i < a; i++) { while(w[va[cur]] < x[i]) { s.push_back(make_pair(s[va[cur]], va[cur])); } int cs = 0; while(cs < t) { if(s.empty()) break; pair <int, int> temp = s.front(); s.pop_back(); cs++; marc[temp.second] = 1; } } priority_queue <pair <int, int> > s2; for(int i = 0; i < n; i++) { if(marc[i] == 0) s2.insert(make_pair(-s[i], i)); } for(int i = b - 1; i >= 0; i--) { int cs = 0; while(cs < t) { if(s2.empty()) break; pair <int, int> temp = s.front(); if(-temp.first >= y[i]) break; s.pop_back(); cs++; } } return ts == n; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { n = T; a = A; b = B; for(int i = 0; i < T; i++) { va[i] = i; vb[i] = i; w[i] = W[i]; s[i] = S[i]; } sort(va, va + n, cmp1); sort(vb, vb + n, cmp2); for(int i = 0; i < a; i++) x[i] = X[i]; for(int i = 0; i < b; i++) y[i] = Y[i]; sort(x, x + a); sort(y, y + b); int ini = 1, fim = MAXN; while(ini < fim) { for(int i = 0; i < t; i++) marc[i] = 0; int m = (ini + fim) / 2; if(teste(m)) { fim = m; } else ini = m + 1; } if(ini == MAXN) ini = -1; return ini; }

Compilation message (stderr)

robots.cpp: In function 'bool teste(int)':
robots.cpp:25:15: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'push_back'
   25 |             s.push_back(make_pair(s[va[cur]], va[cur]));
      |               ^~~~~~~~~
robots.cpp:25:36: error: no match for 'operator[]' (operand types are 'std::priority_queue<std::pair<int, int> >' and 'int')
   25 |             s.push_back(make_pair(s[va[cur]], va[cur]));
      |                                    ^
robots.cpp:30:38: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'front'
   30 |             pair <int, int> temp = s.front();
      |                                      ^~~~~
robots.cpp:31:15: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'pop_back'
   31 |             s.pop_back();
      |               ^~~~~~~~
robots.cpp:38:29: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'insert'
   38 |         if(marc[i] == 0) s2.insert(make_pair(-s[i], i));
      |                             ^~~~~~
robots.cpp:38:48: error: no match for 'operator[]' (operand types are 'std::priority_queue<std::pair<int, int> >' and 'int')
   38 |         if(marc[i] == 0) s2.insert(make_pair(-s[i], i));
      |                                                ^
robots.cpp:44:38: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'front'
   44 |             pair <int, int> temp = s.front();
      |                                      ^~~~~
robots.cpp:46:15: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'pop_back'
   46 |             s.pop_back();
      |               ^~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:67:28: error: 't' was not declared in this scope
   67 |         for(int i = 0; i < t; i++) marc[i] = 0;
      |                            ^