Submission #88637

# Submission time Handle Problem Language Result Execution time Memory
88637 2018-12-07T08:15:45 Z Nucleist Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 484 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, std::vector<int> w) {
    int k = w.size();
     vector <int> kk;
     bool n =false;
    for(int i=0;i<w.size();i++)
    {
        if(w[i]==0&&min(l,u)==0)
            {kk.push_back(i);
            n=true;}
    }
    if(!n)
    {int f = l;
    int compteur=0;
    l=u;
    int n = k;
   if(l==0&&u==0)
    return kk;
   if(f==0&&f<u)
    f++;
    int sum = max(f,l);
    bool subset[k+1][max(f,l)+1];
    for (int i = 0; i <= n; i++)
      subset[i][0] = true;
    for (int i = 1; i <= sum; i++)
      subset[0][i] = false;
    for (int i = 1; i <= n; i++)
     {
       for (int j = 1; j <= sum; j++)
       {
         if(j<w[i-1])
         subset[i][j] = subset[i-1][j];
         if (j >= w[i-1])
           subset[i][j] = subset[i-1][j] ||
                                 subset[i - 1][j-w[i-1]];
       }
     }
     bool ka = false;
     for (int j = min(l,f); j <= max(l,f); j++)
     {
         {int kaa=j;
          if(subset[n][j])
          {
              for(int i = n;i>=1;i--)
              {

                  if(subset[i-1][kaa-w[i-1]])
                  {
                    kk.push_back(w[i-1]);
                    kaa -= w[i-1];
                    compteur++;
                    ka=true;
                    if(kaa==0)
                        break;
                  }
              }
          }}
          if(ka)
            break;
     }}
    return kk;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++)
                 ~^~~~~~~~~
molecules.cpp:21:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(f==0&&f<u)
    ^~
molecules.cpp:23:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     int sum = max(f,l);
     ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 484 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 484 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 484 KB Integer 51 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 484 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 484 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 484 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 484 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 484 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 484 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 484 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 484 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -