Submission #53967

# Submission time Handle Problem Language Result Execution time Memory
53967 2018-07-02T06:04:02 Z Alexa2001 Detecting Molecules (IOI16_molecules) C++17
0 / 100
3 ms 756 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

vector< pair<int,int> > W;
vector<ll> S;

vector<int> solution(int x, int y)
{
    vector<int> ans;
    for(int i=x; i<=y; ++i)
        ans.push_back(W[i].second);
    return ans;
}

vector<int> find_subset(int L, int R, vector<int> w)
{
    int i, j;

    for(i=0; i<w.size(); ++i) W.push_back({w[i], i});
    sort(W.begin(), W.end());

    ll sum = 0;
    for(i=0; i<W.size(); ++i)
    {
        sum += W[i].first;
        S.push_back(sum);
    }

    j = 0;
    while(j<S.size() && S[j] < L) ++j;
    if(S[j] <= R)
        return solution(0, j);

    for(i=0; i<S.size(); ++i)
    {
        while(j<S.size() && S[j] - S[i] < L) ++j;
        if(j<S.size() && S[j] - S[i] <= R) return solution(i+1, j);
    }

    return vector<int> ();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<w.size(); ++i) W.push_back({w[i], i});
              ~^~~~~~~~~
molecules.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<W.size(); ++i)
              ~^~~~~~~~~
molecules.cpp:33:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(j<S.size() && S[j] < L) ++j;
           ~^~~~~~~~~
molecules.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<S.size(); ++i)
              ~^~~~~~~~~
molecules.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j<S.size() && S[j] - S[i] < L) ++j;
               ~^~~~~~~~~
molecules.cpp:40:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(j<S.size() && S[j] - S[i] <= R) return solution(i+1, j);
            ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 452 KB OK (n = 12, answer = YES)
2 Correct 2 ms 696 KB OK (n = 12, answer = YES)
3 Correct 3 ms 696 KB OK (n = 12, answer = NO)
4 Correct 2 ms 696 KB OK (n = 12, answer = NO)
5 Correct 2 ms 696 KB OK (n = 12, answer = YES)
6 Correct 2 ms 724 KB OK (n = 12, answer = YES)
7 Correct 2 ms 744 KB OK (n = 12, answer = YES)
8 Correct 2 ms 756 KB OK (n = 12, answer = YES)
9 Correct 2 ms 756 KB OK (n = 6, answer = YES)
10 Correct 2 ms 756 KB OK (n = 12, answer = YES)
11 Incorrect 2 ms 756 KB Integer 101 violates the range [0, 100]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -