Submission #1001952

#TimeUsernameProblemLanguageResultExecution timeMemory
1001952ayankarimovaDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>ans; map<ll, ll>mp; map<ll, vector<ll>>mp1; for(int i=0; i<w.size(); i++){ mp[w[i]]++; mp1[w[i]].push_back(i); } //cout<<mp[6]<<endl; for(auto i:mp){ ll num=(l+i.first-1)/i.first; if(num<=i.second && num*i.first<=u && num*i.first>=l){ for(auto j:mp1[i.first]){ ans.push_back(j); if(ans.size()==num) break; } //cout<<1<<endl; return ans; } if(mp.count(i.first+1)>0){ ll cur=l-i.second*i.first; ll num1=(cur+(i.first+1)-1)/(i.first+1); if(num1<=mp[i.first+1] && i.second*i.first+num1*(i.first+1)<=u && i.second*i.first+num1*(i.first+1)>=l && u-l>=1){ for(auto j:mp1[i.first]){ ans.push_back(j); if(ans.size()==i.second) break; } for(auto j:mp1[i.first+1]){ ans.push_back(j); if(ans.size()==i.second+num1) break; } //cout<<2<<endl; return ans; } } if(mp.count(i.first-1)>0 &&&& u-l>=1){ ll cur=l-i.second*i.first; ll num1=(cur+(i.first-1)-1)/(i.first-1); if(num1<=mp[i.first-1] && i.second*i.first+num1*(i.first-1)<=u && i.second*i.first+num1*(i.first-1)>=l){ for(auto j:mp1[i.first]){ ans.push_back(j); if(ans.size()==i.second) break; } for(auto j:mp1[i.first-1]){ ans.push_back(j); if(ans.size()==i.second+num1) break; } //cout<<2<<endl; return ans; } } } return ans; } /* {} [] 7 13 14 2 2 3 3 3 4 4 */

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0; i<w.size(); i++){
      |                  ~^~~~~~~~~
molecules.cpp:19:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |                 if(ans.size()==num) break;
      |                    ~~~~~~~~~~^~~~~
molecules.cpp:30:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |                         if(ans.size()==i.second) break;
      |                            ~~~~~~~~~~^~~~~~~~~~
molecules.cpp:34:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   34 |                         if(ans.size()==i.second+num1) break;
      |                            ~~~~~~~~~~^~~~~~~~~~~~~~~
molecules.cpp:40:44: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   40 |             if(mp.count(i.first-1)>0 &&&& u-l>=1){
      |                                        ~~~~^~
molecules.cpp:40:46: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   40 |             if(mp.count(i.first-1)>0 &&&& u-l>=1){
      |                                        ~~~~~~^~~
molecules.cpp:46:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   46 |                         if(ans.size()==i.second) break;
      |                            ~~~~~~~~~~^~~~~~~~~~
molecules.cpp:50:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   50 |                         if(ans.size()==i.second+num1) break;
      |                            ~~~~~~~~~~^~~~~~~~~~~~~~~
molecules.cpp:40:43: error: label 'u' used but not defined
   40 |             if(mp.count(i.first-1)>0 &&&& u-l>=1){
      |                                           ^