Submission #209404

# Submission time Handle Problem Language Result Execution time Memory
209404 2020-03-14T06:13:28 Z Autoratch Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 380 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

deque<pair<int,int> > q;
vector<pair<int,int> > a;
int sum,idx;

vector<int> find_subset(int x,int y,vector<int> b)
{
    for(int i = 0;i < b.size();i++) a.push_back({b[i],i+1});
    sort(a.begin(),a.end());
    while(true)
    {
        if(sum<x)
        {
            if(idx==a.size()) return vector<int>(0);
            q.push_back(a[idx]),sum+=a[idx].first;
            idx++;
        }
        else if(sum>y)
        {
            sum-=q.front().first;
            q.pop_front();
        }
        else
        {
            vector<int> ans;
            for(auto p : q) ans.push_back(p.second);
            return ans;
        }
    }
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < b.size();i++) a.push_back({b[i],i+1});
                   ~~^~~~~~~~~~
molecules.cpp:17:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(idx==a.size()) return vector<int>(0);
                ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 380 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 380 KB OK (n = 12, answer = YES)
2 Correct 4 ms 376 KB OK (n = 12, answer = YES)
3 Correct 5 ms 256 KB OK (n = 12, answer = NO)
4 Correct 5 ms 376 KB OK (n = 12, answer = NO)
5 Incorrect 5 ms 256 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 380 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 380 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 380 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 5 ms 380 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -