fork download
  1. class Solution {
  2. public:
  3. int minimizeTheDifference(vector<vector<int>>& mat, int target) {
  4. bitset<4901>p(1);
  5. for (auto row : mat) {
  6. bitset<4901>pp;
  7. for(auto i:row){
  8. pp|=(p<<i);
  9. }
  10. swap(p,pp);
  11. }
  12.  
  13.  
  14. int res = INT_MAX;
  15. for (int i = 0; i < 4901;i++) {
  16. if (p[i])res=min(res, abs(i - target));
  17. }
  18. return res;
  19. }
  20. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:31: error: ‘vector’ has not been declared
     int minimizeTheDifference(vector<vector<int>>& mat, int target) {
                               ^~~~~~
prog.cpp:3:37: error: expected ‘,’ or ‘...’ before ‘<’ token
     int minimizeTheDifference(vector<vector<int>>& mat, int target) {
                                     ^
prog.cpp: In member function ‘int Solution::minimizeTheDifference(int)’:
prog.cpp:4:9: error: ‘bitset’ was not declared in this scope
         bitset<4901>p(1);
         ^~~~~~
prog.cpp:4:21: error: ‘p’ was not declared in this scope
         bitset<4901>p(1);
                     ^
prog.cpp:5:25: error: ‘mat’ was not declared in this scope
         for (auto row : mat) {
                         ^~~
prog.cpp:6:25: error: ‘pp’ was not declared in this scope
             bitset<4901>pp;
                         ^~
prog.cpp:7:24: error: unable to deduce ‘auto&&’ from ‘row’
             for(auto i:row){
                        ^~~
prog.cpp:10:13: error: ‘swap’ was not declared in this scope
             swap(p,pp);
             ^~~~
prog.cpp:14:19: error: ‘INT_MAX’ was not declared in this scope
         int res = INT_MAX;
                   ^~~~~~~
prog.cpp:14:19: note: ‘INT_MAX’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
prog.cpp:1:1:
+#include <climits>
 class Solution {
prog.cpp:14:19:
         int res = INT_MAX;
                   ^~~~~~~
prog.cpp:16:43: error: ‘target’ was not declared in this scope
             if (p[i])res=min(res, abs(i - target));
                                           ^~~~~~
prog.cpp:16:35: error: ‘abs’ was not declared in this scope
             if (p[i])res=min(res, abs(i - target));
                                   ^~~
prog.cpp:16:26: error: ‘min’ was not declared in this scope
             if (p[i])res=min(res, abs(i - target));
                          ^~~
stdout
Standard output is empty