제출 #897955

#제출 시각아이디문제언어결과실행 시간메모리
897955duckindogDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms2396 KiB
// from duckindog wth depression #include<bits/stdc++.h> using namespace std; //#define LOCAL #ifndef LOCAL #include "molecules.h" #endif // LOCAL struct T { int a, b; T(int aa, int bb) : a(aa), b(bb) {} }; const int N = 1e4 + 1; bool f[2][N]; pair<int, int> trace[N][N]; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); for (int i = 1; i < n; ++i) { int it = i - 1 & 1; for (int j = 1; j <= u; ++j) f[1 - it][j] = 0; f[1 - it][0] = f[1 - it][w[i - 1]] = 1; for (int j = 1; j <= u; ++j) { auto &ret = f[it][j]; if (f[1 - it][j]) { ret = 1; trace[i][j] = {i - 1, j}; } if (j - w[i] >= 0 && f[1 - it][j - w[i]]) { ret = 1; trace[i][j] = {i - 1, j - w[i]}; } } } vector<int> answer; int i = n - 1, j = 0; for (int x = l; x <= u; ++x) if (f[i & 1][x]) j = x; while (j) { int pi, pj; tie(pi, pj) = trace[i][j]; if (j > pj) answer.push_back(i); i = pi; j = pj; } return answer; } #ifdef LOCAL int32_t main() { cin.tie(0)->sync_with_stdio(0); if (fopen("duck.inp", "r")) { freopen("duck.inp", "r", stdin); freopen("duck.out", "w", stdout); } int l, u; cin >> l >> u; int x; vector<int> input; while (cin >> x) input.push_back(x); for (auto i : find_subset(l, u, input)) cout << i << ' '; } #endif // LOCAL

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:16: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   24 |     int it = i - 1 & 1;
      |              ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...