Submission #1165053

#TimeUsernameProblemLanguageResultExecution timeMemory
1165053chikien2009Detecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; // inline void setup() // { // #ifndef ONLINE_JUDGE // freopen("test.inp", "r", stdin); // freopen("test.out", "w", stdout); // #endif // ios_base::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); // } vector<int> find_subset(short l, short u, vector<int> w) { queue<short> q; vector<int> res, vector<short> p[w.size()]; short sum = 0, x = -1; for (short i = 0; i < w.size(); ++i) { p[i].resize(u + 1); for (short j = 0; j <= u; ++j) { p[i][j] = (i == 0 ? -1 : p[i - 1][j]); } for (short j = u; j >= w[i]; --j) { if (p[i][j - w[i]] != -1 || j == w[i]) { p[i][j] = i; if (l <= j && x == -1) { x = j; } } } } for (short i = w.size() - 1, j; i >= 0 && x > 0;) { j = p[i][x]; res.push_back(p[i][x]); while (0 <= i && p[i][x] == res.back()) { i--; } x -= w[res.back()]; } reverse(res.begin(), res.end()); return res; } // short main() // { // setup(); // short n, u, l; // vector<short> v; // cin >> n >> l >> u; // v.resize(n); // for (short i = 0; i < n; ++i) // { // cin >> v[i]; // } // v = find_subset(l, u, v); // for (auto & i : v) // { // cout << i << " "; // } // return 0; // }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(short int, short int, std::vector<int>)':
molecules.cpp:21:19: error: invalid declarator before 'p'
   21 |     vector<short> p[w.size()];
      |                   ^
molecules.cpp:25:9: error: 'p' was not declared in this scope
   25 |         p[i].resize(u + 1);
      |         ^
molecules.cpp:44:13: error: 'p' was not declared in this scope
   44 |         j = p[i][x];
      |             ^
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
      |         ^~~~