Submission #287627

# Submission time Handle Problem Language Result Execution time Memory
287627 2020-08-31T21:33:15 Z Ruba_K Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 256 KB
#include "molecules.h"

#include<bits/stdc++.h>

using namespace std ;

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();

    map<int , int > mp;

    for(auto f : w)
        mp[f]++;

    int first , second ;
    int n1 , n2 ;
    first = mp[w[0]] , n1 = w[0];
    if(mp.size() == 1)second = 0 , n2 = 0 ;
    else {
        for(auto f : mp){
            if(f.first != n1){
                n2 = f.first ;
                second = f.second ;

                break;
            }
        }
    }

    vector<int>ans ;

    for(int i = 0 ; i <= first ; i ++){

        for(int j = 0 ; j <= second ; j ++){
            int sum = j * n1 + i * n2 ;

            if(sum >= l && sum <= u){
                map<int , int > cnt ;
                for(int c = 0 ; c < n ; c ++){
                    if(w[c] == n1 && cnt[n1] == i)continue ;
                    if(w[c] == n2 && cnt[n2] == j)continue ;

                    cnt[w[c]]++;
                    ans.push_back(c );
                }
            }
            if(ans.size())break;
        }
        if(ans.size())break;
    }



    return ans ;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:34:27: warning: 'second' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |         for(int j = 0 ; j <= second ; j ++){
      |                         ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 12, answer = YES)
2 Correct 0 ms 256 KB OK (n = 12, answer = YES)
3 Correct 1 ms 256 KB OK (n = 12, answer = NO)
4 Correct 1 ms 256 KB OK (n = 12, answer = NO)
5 Incorrect 1 ms 256 KB sum of weights should be in [290..300] but it is 306
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -