Submission #1001354

#TimeUsernameProblemLanguageResultExecution timeMemory
1001354Br3adDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms360 KiB
#include <iostream> #include <fstream> #include <iomanip> #include <algorithm> #include <functional> #include <numeric> #include <cstring> #include <string> #include <cmath> #include <vector> #include <queue> #include <stack> #include <set> #include <map> using namespace std; #define ll long long #define ull unsigned long long #define f first #define s second #define PF push_front #define PB push_back #define MP make_pair #define max(a, b) ((a > b)? a : b) #define min(a, b) ((a < b)? a : b) #define max3(a, b, c) max(max(a, b), c) #define min3(a, b, c) min(min(a, b), c) const int N = 2e5 + 5; const int M = 1e9 + 7; const int inf = 0x3f3f3f3f; const ll int INF = 1e18; vector<int> find_subset(int l, int u, vector<int> w){ // DP may pass O(NU) const int MAXN = 1e4 + 5; vector<int> dp(MAXN, false), parent(MAXN, -1); dp[0] = true; int ans = -1; for(int i = 0; i < w.size() && ans == -1; i++){ for(int j = MAXN-1; j >= w[i] && ans == -1; j--){ if(dp[j]) continue; dp[j] |= dp[j - w[i]]; if(dp[j]) parent[j] = i; if(dp[j] && j >= l && j <= u) ans = j; } } vector<int> v; for(int cur = ans; cur > 0; cur -= w[parent[cur]]){ v.PB(parent[cur] + 1); } if(v.empty()) v.PB(-1); return v; } // int main(){ // ios::sync_with_stdio(false); // cin.tie(NULL); // // ifstream cin(); // // ofstream cout(); // vector<int> temp; // // temp = find_subset(15, 17, {6, 8, 8, 7}); // // temp = find_subset(14, 15, {5, 5, 6, 6}); // temp = find_subset(10, 20, {15, 17, 16, 18}); // for(int i : temp){ // cout << i << ' '; // } // }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0; i < w.size() && ans == -1; i++){
      |                    ~~^~~~~~~~~~
#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...