제출 #730786

#제출 시각아이디문제언어결과실행 시간메모리
730786ETheBest3Detecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms340 KiB
#include<bits/stdc++.h>
#include "molecules.h"
#define lli int
using namespace std;
vector<lli> ans, otg;
vector<pair<lli, lli>> W;
lli N;
bool used[200005];
void to_otg(){
    for(lli i=0; i<ans.size(); i++){
        otg.push_back(W[ans[i]].second);
    }
    return;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    for(lli i=0; i<w.size(); i++)W.push_back({w[i], i});
    sort(W.begin(), W.end());
    N=W.size();
    lli p1=0, p2=0, sum=0;
    while(sum<=l and p2<N){
        if(sum+W[p2].first>l)break;
        sum+=W[p2].first;
        ans.push_back(p2);
        p2++;
    }
    if(sum==l){
        to_otg();
        return otg;
    }
    if(p2<N and sum+W[p2].first>=l and sum+W[p2].first<=u){
        ans.push_back(p2);
        to_otg();
        return otg;
    }
    if(ans.size()==0)return vector<int>(0);
    while(p2<N){
        sum+=W[p2].first-W[p1].first;
        ans[p1]=p2;
        if(sum>=l and sum<=u)break;
        p1++;
        p2++;
    }
    if(sum<l or sum>u)return vector<int>(0);
    to_otg();
    return otg;
}

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

molecules.cpp: In function 'void to_otg()':
molecules.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(lli i=0; i<ans.size(); i++){
      |                  ~^~~~~~~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(lli i=0; i<w.size(); i++)W.push_back({w[i], i});
      |                  ~^~~~~~~~~
#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...