제출 #1102162

#제출 시각아이디문제언어결과실행 시간메모리
1102162akzytrDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> result; int n = w.size(); bool dp[u + 1]; bool dp2[u + 1]; int back[u + 1]; for(int i = 0; i <= n; i++) { for(int j = 0; j <= u; j++) { dp[i][j] = 0; back[j] = -1; } } dp[0] = 1; back[0] = 0; for(int i = 1; i <= n; i++) { for(int s = 0; s <= u; s++) { if(s < w[i - 1]) { dp2[s] = dp[s]; } else if(dp[s - w[i - 1]]) { dp2[s] = 1; if(back[s] == -1) { back[s] = i; } } else { dp2[s] = dp[s]; } } for(int s = 0; s <= u; s++) { dp[s] |= dp2[s]; } } for(int i = l; i <= u; i++) { if(back[i] != -1) { int idx = back[i]; int s = i; while(idx != 0) { result.push_back(idx - 1); s -= w[idx - 1]; idx = back[s]; } break; } } return result; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:9: error: invalid types 'bool[int]' for array subscript
   16 |    dp[i][j] = 0;
      |         ^