Submission #774588

#TimeUsernameProblemLanguageResultExecution timeMemory
774588JMsDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { unsigned const long long tam = 100005; long long v[tam], aux, c=0, ph, pl, s; vector <int> result; for( long long i=0; i<w.size(); i++){ v[i]=i; } for( long long i=0; i<w.size()-1; i++){ for( long long j=i+1; j<w.size(); j++){ if(w[i]>w[j]){ aux=w[j]; w[j]=w[i]; w[i]=aux; aux=v[j]; v[j]=v[i]; v[i]=aux; } } } pl=0; ph=0; s=w[0]; while(1){ //cout<<pl<<" "<<ph<<" "<<s<<endl; if(s<l && ph<w.size()-1){ ph++; s+=w[ph]; } else if(s>u && pl<ph){ s-=w[pl]; pl++; } else if( ph==w.size()-1 && (s>u || s<l)){ return vector<int>(); break; } else{ for( long long i=pl; i<=ph; i++){ result.push_back(v[i]); } break; } } return result; } int main() { unsigned const long long tam=100005; int l, u, n; vector <int> w; cin>>l>>u>>n; for(long long i=0; i<n; i++){ cin>>w[i]; } find_subset(l, u, w); return 0; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         for( long long i=0; i<w.size(); i++){
      |                             ~^~~~~~~~~
molecules.cpp:13:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for( long long i=0; i<w.size()-1; i++){
      |                             ~^~~~~~~~~~~
molecules.cpp:14:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |             for( long long j=i+1; j<w.size(); j++){
      |                                   ~^~~~~~~~~
molecules.cpp:30:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if(s<l && ph<w.size()-1){
      |                       ~~^~~~~~~~~~~
molecules.cpp:38:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             else if( ph==w.size()-1 && (s>u || s<l)){
      |                      ~~^~~~~~~~~~~~
molecules.cpp:8:32: warning: unused variable 'c' [-Wunused-variable]
    8 |         long long v[tam], aux, c=0, ph, pl, s;
      |                                ^
molecules.cpp: In function 'int main()':
molecules.cpp:54:34: warning: unused variable 'tam' [-Wunused-variable]
   54 |         unsigned const long long tam=100005;
      |                                  ^~~
/usr/bin/ld: /tmp/cch81Mcf.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cczuvACh.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status