Submission #960224

# Submission time Handle Problem Language Result Execution time Memory
960224 2024-04-09T23:59:45 Z RyaroX Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef int ll;
ll dp[20005][2];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    ll n=w.size();
    ll d=0;
    dp[0][1]=1;
    for(ll i=0;i<n;i++){
        ll a=w[i];
        for(ll j=u;j>=0;j--){
            if(dp[j][1]>0){
                dp[j+a][1]=a;
                dp[j+a][0]=i;
                if(j+a>=l and j+a<=u){
                    ll s=j+a;
                    vector <ll> V;
                    while(s>0){
                        //cout<<s<<" "<<dp[s]<<"\n";
                        V.push_back(dp[s][0]);
                        s=s-dp[s][1];
                    }
                    reverse(V.begin(), V.end());
                    return V;
                }
            }

        }
    }
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:8: warning: unused variable 'd' [-Wunused-variable]
    8 |     ll d=0;
      |        ^
molecules.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB item #5 is taken twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -