Submission #1288769

#TimeUsernameProblemLanguageResultExecution timeMemory
1288769muhammad-ahmadDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); int a[n + 1]; for (int i = 0; i < n; i++) a[i + 1] = w[i]; int pref[n + 2] = {}, suf[n + 2] = {}; map<int, int> C; for (int i = 1; i <= n; i++){ pref[i] = a[i] + pref[i - 1]; } for (int i = n; i >= 1; i--){ suf[i] = suf[i + 1] + a[i]; } S[0] = 1e18; r = n; while (suf[r] < l) r--; for (int L = 0; L <= n; L++){ while (R <= n && pref[L] + suf[R]) R++; if (pref[L] + suf[R] >= l && pref[L] + suf[R] <= u){ vector<int> ans; for (int i = 1; i <= L; i++) ans.push_back(a[i]); for (int i = R; i <= n; i++) ans.push_back(a[i]); return ans; } } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:20:9: error: 'S' was not declared in this scope
   20 |         S[0] = 1e18;
      |         ^
molecules.cpp:21:9: error: 'r' was not declared in this scope
   21 |         r = n;
      |         ^
molecules.cpp:24:24: error: 'R' was not declared in this scope
   24 |                 while (R <= n && pref[L] + suf[R]) R++;
      |                        ^
molecules.cpp:26:35: error: 'R' was not declared in this scope
   26 |                 if (pref[L] + suf[R] >= l && pref[L] + suf[R] <= u){
      |                                   ^
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
      |         ^~~~