제출 #639970

#제출 시각아이디문제언어결과실행 시간메모리
639970rc_catuntaDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms212 KiB
#include "molecules.h" #include <vector> #include <algorithm> #include <iostream> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { // Desempaquetar en un vector de pairs vector< pair<int,int> > v; int mini = w[0]; int maxi = w[0]; vector<int> pos_menor,pos_mayor,res; for(int i=0;i<w.size();i++){ mini = min(mini,w[i]); maxi = max(maxi,w[i]); } if(mini == maxi){ int suma = 0; for(int i=0;i<w.size();i++){ suma+=w[i]; res.push_back(i); if(suma>=l and suma<=u) return res; } res.clear(); return res; } for(int i=0;i<w.size();i++){ if(w[i]==mini) pos_menor.push_back(i); if(w[i]==maxi) pos_mayor.push_back(i); } for(int i=0;i<=pos_menor.size();i++){ for(int j=0;j<=pos_mayor.size();j++){ int suma=mini*i+maxi*j; if(suma>=l and suma<=u){ for(int k=0;k<i;k++) res.push_back(pos_menor[k]); for(int k=0;k<j;k++) res.push_back(pos_mayor[k]); return res; } } } res.clear(); return res; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int i=0;i<w.size();i++){
      |                     ~^~~~~~~~~
molecules.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0;i<=pos_menor.size();i++){
      |                 ~^~~~~~~~~~~~~~~~~~
molecules.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j=0;j<=pos_mayor.size();j++){
      |                     ~^~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...