제출 #270151

#제출 시각아이디문제언어결과실행 시간메모리
270151Mounir로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "robots.h" #define all(v) v.begin(), v.end() #define chmax(x, v) x = max(x, v) #define chmin(x, v) x = min(x, v) #define sz(v) (int)v.size() #define pb push_back //#define int long long using namespace std; struct Chose { bool estRobot; bool triTaille; int taille, poids; bool operator < (const Chose &autre) const { if (triTaille && taille != autre.taille) return taille < autre.taille; else if (!triTaille && poids != autre.poids) return poids < autre.poids; else if (estRobot != autre.estRobot) return estRobot; return false; } void dbg(){ return; cout << estRobot << " " << triTaille << " " << taille << " " << poids << endl; } }; int nFragiles, nPetits; int nJouets; vector<Chose> jouets, robotsFragiles, robotsPetits; vector<Chose> objets; bool fonctionne (int limite){ priority_queue<Chose> jouetsPasRanges; for (Chose& objet : objets){ if (objet.estRobot){ int nPris = 0; while (!jouetsPasRanges.empty() && nPris < limite){ jouetsPasRanges.pop(); nPris++; } } else { objet.triTaille = true; jouetsPasRanges.push(objet); objet.triTaille = false; } } //Il reste quelque truc qu'on va essayer de recup vector<Chose> objetsn; while (!jouetsPasRanges.empty()){ Chose jouet = jouetsPasRanges.top(); jouet.triTaille = true; objetsn.pb(jouet); jouetsPasRanges.pop(); } for (Chose& robotPetit : robotsPetits){ robotPetit.triTaille = true; objetsn.pb(robotPetit); } sort(all(objetsn)); //cout << "LMT " << limite << endl; for (Chose& objet : objetsn){ if (objet.estRobot){ int nPris = 0; while (!jouetsPasRanges.empty() && nPris < limite){ jouetsPasRanges.pop(); nPris++; } } else { objet.triTaille = false; jouetsPasRanges.push(objet); } } return jouetsPasRanges.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ nFragiles = A; nPetits = B; nJouets = T; for (int ind = 0; ind < nFragiles; ++ind) robotsFragiles.pb({true, false, -1, X[ind]}); for (int ind = 0; ind < nPetits; ++ind) robotsPetits.pb({true, true, Y[ind], -1}); for (int ind = 0; ind < nJouets; ++ind) jouets[ind].pb({false, false, S[ind], W[ind]}); for (Chose& jouet : jouets){ jouet.triTaille = false; objets.pb(jouet); } for (Chose& robotFragile : robotsFragiles) objets.pb(robotFragile); sort(all(objets)); int deb = (nJouets)/(nFragiles + nPetits), fin = nJouets + 1; while (fin > deb){ int milieu = (deb + fin)/2; // cout << deb << " " << fin << " " << milieu << " " << fonctionne(milieu) << endl; if (fonctionne(milieu)) fin = milieu; else deb = milieu + 1; } if (deb > nJouets) return -1; return deb; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:7:12: error: '__gnu_cxx::__alloc_traits<std::allocator<Chose>, Chose>::value_type' {aka 'struct Chose'} has no member named 'push_back'
    7 | #define pb push_back
      |            ^~~~~~~~~
robots.cpp:104:15: note: in expansion of macro 'pb'
  104 |   jouets[ind].pb({false, false, S[ind], W[ind]});
      |               ^~