제출 #348728

#제출 시각아이디문제언어결과실행 시간메모리
348728NachoLibreDetecting Molecules (IOI16_molecules)C++14
19 / 100
1 ms512 KiB
#include <bits/stdc++.h>
using namespace std;
#ifndef wambule
#include "molecules.h"
#endif

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<int> dr;
    int n = w.size();
    multiset<int> s;
    unsigned int sm = 0;
    s.insert(0);
    for(int i = n - 1; i >= 0; --i) {
        sm += w[i];
        if(sm <= u) s.insert(sm);
        if(sm >= l) break;
    }
    sm = 0;
    int fl = -1, fr;
    if(*(--s.end()) >= l) fl = 0, fr = *(--s.end());
    for(int i = 0; i < n; ++i) {
        if(i + (int)s.size() == n + 1) s.erase(--s.end());
        sm += w[i];
        if(sm >= l) {
            if(sm <= u) {
                fl = sm;
                fr = 0;
            }
            break;
        }
        auto it = s.lower_bound(l - sm);
        if(it != s.end() && sm + *it <= u) {
            fl = sm;
            fr = *it;
        }
    }
    if(fl != -1) {
        sm = 0;
        for(int i = 0; i < n; ++i) {
            sm += w[i];
            if(sm > fl) break;
            dr.push_back(i);
        }
        sm = 0;
        for(int i = n - 1; i >= 0; --i) {
            sm += w[i];
            if(sm > fr) break;
            dr.push_back(i);
        }
    }
    assert(dr.size() <= n);
    return dr;
}

#ifdef wambule
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	return 0;
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:15: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   15 |         if(sm <= u) s.insert(sm);
      |            ~~~^~~~
molecules.cpp:16:15: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   16 |         if(sm >= l) break;
      |            ~~~^~~~
molecules.cpp:24:15: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   24 |         if(sm >= l) {
      |            ~~~^~~~
molecules.cpp:25:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   25 |             if(sm <= u) {
      |                ~~~^~~~
molecules.cpp:32:38: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   32 |         if(it != s.end() && sm + *it <= u) {
      |                             ~~~~~~~~~^~~~
molecules.cpp:41:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   41 |             if(sm > fl) break;
      |                ~~~^~~~
molecules.cpp:47:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   47 |             if(sm > fr) break;
      |                ~~~^~~~
In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from molecules.cpp:1:
molecules.cpp:51:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     assert(dr.size() <= n);
      |            ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...