Submission #240243

# Submission time Handle Problem Language Result Execution time Memory
240243 2020-06-18T23:44:37 Z Amy313 Detecting Molecules (IOI16_molecules) C++14
0 / 100
4 ms 384 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
    vector<pair<int, int> >M;
    vector<int> A;
    int s, n = w.size(), c;
    for(int i=0; i<w.size(); i++)
    {
        M.push_back(make_pair(w[i], i));
    }
    sort(M.begin(), M.end());
    A.clear();
    if(M[0].first>u)
	{
		return A;
	}
    for(int i=n-1; i>=0; i--)
    {
        s = M[i].first;
        c =0;
        A.push_back(M[i].second);
        if(s<l)
        {
            for(int j=0; j<w.size(); j++)
            {
            	s+=M[j].first;
            	A.push_back(M[j].second);
            	if(s>=l and s<=u)
				{
					c = 1;
					break;
				}
				else
				{
					if(s>u)
					{
						
						break;
					}
				}
            }
            if(c==1)
			{
				break;
			}
        }
        else
		{
			if(s<=u)
			{
				break;
			}
		}
    }
    return A;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<w.size(); i++)
                  ~^~~~~~~~~
molecules.cpp:26:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0; j<w.size(); j++)
                          ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 128 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Integer 84 violates the range [0, 12]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 128 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 128 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 128 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 128 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -