Submission #1141339

#TimeUsernameProblemLanguageResultExecution timeMemory
1141339harry_tm_18Detecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5; vector<int> adj[N]; vector<bool> c(N); vector<int> find_subset(int l, int u, vector<int> w){ int n = w.size(); vector<pair<ll,ll>> a; for(int i=0; i<n; ++i){ a.emplace_back(w[i],i); } sort(a.begin(), a.end()); vector<ll> suffix(n) vector<int> ans; suffix[n-1] = a[n-1].first; for(int i=n-2; i>=0; --i){ suffix[i] = suffix[i+1] + a[i].first; } ll prefixSum = 0; for(int i=0; i<n; ++i){ if(prefixSum > u) break; if(prefixSum <= l){ for(int j=0; j<=i; ++i){ ans.push_back(a[j].second); } return ans; } ll v = i, g = n-1; while(v <= g){ int mid = v + (g - v) / 2; if(prefixSum + suffix[mid] >= l && prefixSum + suffix[mid] <= u){ for(int j=0; j<i; ++j){ ans.push_back(a[j].second); } for(int j=mid+1; j<n; ++j){ ans.push_back(a[j].second); } return ans; } else if(prefixSum + suffix[mid] > u){ v = mid + 1; } else { g = mid - 1; } } prefixSum += a[i].first; } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:9: error: expected ',' or ';' before 'vector'
   22 |         vector<int> ans;
      |         ^~~~~~
molecules.cpp:35:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |                     ans.push_back(a[j].second);
      |                     ^~~
      |                     abs
molecules.cpp:37:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |                 return ans;
      |                        ^~~
      |                        abs
molecules.cpp:47:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |                         ans.push_back(a[j].second);
      |                         ^~~
      |                         abs
molecules.cpp:50:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |                         ans.push_back(a[j].second);
      |                         ^~~
      |                         abs
molecules.cpp:52:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |                     return ans;
      |                            ^~~
      |                            abs
molecules.cpp:62:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   62 |         return ans;
      |                ^~~
      |                abs
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
      |         ^~~~