Submission #676990

#TimeUsernameProblemLanguageResultExecution timeMemory
676990DulguunDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; auto find_subset(int l, int u, auto w){ int n = sizeof(w)/sizeof(w[0]); vector<pair<int,int>> v(n); for(int i=0; i<n; i++) v[i]={w[i], i}; sort(v.begin(), v.end()); for(int k=n; k>0; k++){ int s=0; for(int i=0; i<k; i++) s+=v[i]; do{ if(s>=l && s<=u) { int sol[k]; for(int j=0; j<k; j++) sol[j]=v[j].second; return sol; }s=s+v[i]-v[i-k]; } while(int i=k; i<n; i++) } }

Compilation message (stderr)

molecules.cpp:4:32: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    4 | auto find_subset(int l, int u, auto w){
      |                                ^~~~
molecules.cpp: In function 'auto find_subset(int, int, auto:1)':
molecules.cpp:12:27: error: no match for 'operator+=' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   12 |   for(int i=0; i<k; i++) s+=v[i];
molecules.cpp:18:11: error: 'i' was not declared in this scope
   18 |    }s=s+v[i]-v[i-k];
      |           ^
molecules.cpp:20:9: error: expected primary-expression before 'int'
   20 |   while(int i=k; i<n; i++)
      |         ^~~
molecules.cpp:20:9: error: expected ')' before 'int'
   20 |   while(int i=k; i<n; i++)
      |        ~^~~
      |         )
molecules.cpp:20:9: error: expected ';' before 'int'
   20 |   while(int i=k; i<n; i++)
      |         ^~~
      |         ;
molecules.cpp:20:26: error: expected ';' before ')' token
   20 |   while(int i=k; i<n; i++)
      |                          ^
      |                          ;