제출 #432658

#제출 시각아이디문제언어결과실행 시간메모리
432658BelguteiDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms204 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair vector<int> v; vector<pair<int,int> > w; std::vector<int> find_subset(int l, int u, std::vector<int> ww) { for(int i=0; i<ww.size(); i++){ w.pb(mk(ww[i],i)); } sort(w.begin(),w.end()); bool ok=0; for(int k=1; k<=w.size() && ok==0; k++){ ll sum=0; for(int j=0; j<k; j++){ sum+=w[j].ff; } if(sum>u) break; if(l<=sum){ for(int j=0; j<k; j++){ v.pb(w[j].ss); } break; } int x=0; int y=w.size()-1; while(x<y && x<=k-1){ sum-=w[x].ff; sum+=w[y].ff; if(sum>=l){ for(int i=(x+1); i<=k-1; i++){ v.pb(w[i].ss); } for(int i=w.size()-x-1; i<w.size(); i++){ v.pb(w[i].ss); } ok=1; break; } x++; y--; } } return v; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0; i<ww.size(); i++){
      |                  ~^~~~~~~~~~
molecules.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 |     for(int k=1; k<=w.size() && ok==0; k++){
      |                  ~^~~~~~~~~~
molecules.cpp:42:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                 for(int i=w.size()-x-1; i<w.size(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...