Submission #131613

# Submission time Handle Problem Language Result Execution time Memory
131613 2019-07-17T10:30:50 Z neki Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include "molecules.h"

#include <bits/stdc++.h>

#define loop(i, a, b) for(int i=a;i<b;i++)
#define cc(a) cout<< a << endl;
using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    map<int, int> dp;
    vector<int> ans;
    loop(i, 1, w.size()+1){
        auto dp2=dp;
        for(auto&& j: dp) if(j.first+w[i-1]<=u) dp2[j.first+w[i-1]]=i;
        if(dp2[w[i-1]]==0)dp2[w[i-1]]=i;dp=dp2;
        auto it=dp.lower_bound(l);
        if(it!=dp.end()){
            int cnt=it->first;
            while(cnt!=0){
                ans.push_back(dp[cnt]-1);
                cnt-=w[dp[cnt]-1];
            }
            break;
        }
    }
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:5:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define loop(i, a, b) for(int i=a;i<b;i++)
molecules.cpp:12:10:
     loop(i, 1, w.size()+1){
          ~~~~~~~~~~~~~~~~           
molecules.cpp:12:5: note: in expansion of macro 'loop'
     loop(i, 1, w.size()+1){
     ^~~~
molecules.cpp:15:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(dp2[w[i-1]]==0)dp2[w[i-1]]=i;dp=dp2;
         ^~
molecules.cpp:15:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if(dp2[w[i-1]]==0)dp2[w[i-1]]=i;dp=dp2;
                                         ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB item #7 is taken twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -