Submission #1299611

#TimeUsernameProblemLanguageResultExecution timeMemory
1299611gesp3011v2Detecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #include "molecules.h" vector<int> find_subset(int l,int u,vector<int> w){ int n=w.size(); vector<pair<int,int>> X; for(int i=0;i<n;i++)X.push_back({w[i],i}); sort(X.begin(), X.end()); int a[n+1],idx[n+1]; for(int i=0;i<n;i++){ a[i+1]=X[i].first; idx[i+1]=X[i].second; } ll pref[n+1]={},suf[n+1]={}; for(int i=1;i<=n;i++){ pref[i]=pref[i-1]; pref[i]+=a[i]; } for(int i=n;i>=1;i--){ suf[i]=suf[i+1]; suf[i]+=a[i]; } suf[0]=u; suf[0]<<=1; int R=0; for(int L=0;L<=n;L++){ while(R<=n && (ll)(pref[L]+suf[R])>u)R++; ll s=pref[L]+suf[R]; if(s>=l && s<=u && R>L){ vector<int> ans; for(int i=1;i<=L;i++)ans.push_back(idx[i]); for(int i=R;i<=n;i++)ans.push_back(idx[i]); return ans; } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:9: error: 'll' was not declared in this scope; did you mean 'l'?
   15 |         ll pref[n+1]={},suf[n+1]={};
      |         ^~
      |         l
molecules.cpp:15:24: error: expected primary-expression before ',' token
   15 |         ll pref[n+1]={},suf[n+1]={};
      |                        ^
molecules.cpp:15:25: error: 'suf' was not declared in this scope
   15 |         ll pref[n+1]={},suf[n+1]={};
      |                         ^~~
molecules.cpp:17:17: error: 'pref' was not declared in this scope
   17 |                 pref[i]=pref[i-1];
      |                 ^~~~
molecules.cpp:28:36: error: 'pref' was not declared in this scope
   28 |                 while(R<=n && (ll)(pref[L]+suf[R])>u)R++;
      |                                    ^~~~
molecules.cpp:29:19: error: expected ';' before 's'
   29 |                 ll s=pref[L]+suf[R];
      |                   ^~
      |                   ;
molecules.cpp:30:20: error: 's' was not declared in this scope
   30 |                 if(s>=l && s<=u && R>L){
      |                    ^
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~