제출 #489033

#제출 시각아이디문제언어결과실행 시간메모리
4890331neDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; const int MXN = 1e12; std::vector<int> find_subset(int l, int u, std::vector<int> arr) { int n = arr.size(); vector<bitset<MXN>>dp(n+1); dp[0][0]=1; for (int i = 0;i<n;++i){ dp[i+1]|=dp[i]; dp[i+1]|=(dp[i]<<arr[i]); } int val =-1; for (int i = l;i<=u;++i){ if (dp[n][i]){ val = i; break; } } //cout<<val<<'\n'; vector<int>ans; int index = n; while(index>0&&val>0){ if (dp[index-1][val-arr[index-1]]){ ans.push_back(index-1); val-=arr[index-1]; } index--; } return ans; }

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

molecules.cpp:4:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+12' to '2147483647' [-Woverflow]
    4 | const int MXN = 1e12;
      |                 ^~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:19: error: overflow in constant expression [-fpermissive]
    7 |     vector<bitset<MXN>>dp(n+1);
      |                   ^~~
molecules.cpp:7:19: error: overflow in constant expression [-fpermissive]
molecules.cpp:7:19: note: in template argument for type 'long unsigned int'
molecules.cpp:7:22: error: template argument 1 is invalid
    7 |     vector<bitset<MXN>>dp(n+1);
      |                      ^~
molecules.cpp:7:22: error: template argument 2 is invalid
molecules.cpp:8:7: error: invalid types 'int[int]' for array subscript
    8 |     dp[0][0]=1;
      |       ^
molecules.cpp:10:8: error: invalid types 'int[int]' for array subscript
   10 |      dp[i+1]|=dp[i];
      |        ^
molecules.cpp:10:17: error: invalid types 'int[int]' for array subscript
   10 |      dp[i+1]|=dp[i];
      |                 ^
molecules.cpp:11:8: error: invalid types 'int[int]' for array subscript
   11 |      dp[i+1]|=(dp[i]<<arr[i]);
      |        ^
molecules.cpp:11:18: error: invalid types 'int[int]' for array subscript
   11 |      dp[i+1]|=(dp[i]<<arr[i]);
      |                  ^
molecules.cpp:15:12: error: invalid types 'int[int]' for array subscript
   15 |      if (dp[n][i]){
      |            ^
molecules.cpp:24:12: error: invalid types 'int[int]' for array subscript
   24 |      if (dp[index-1][val-arr[index-1]]){
      |            ^