제출 #1011989

#제출 시각아이디문제언어결과실행 시간메모리
1011989hotboy2703Detecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms380 KiB
#include "molecules.h"

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n = sz(w);
    vector <int> order(n);
    iota(order.begin(),order.end(),0);
    sort(order.begin(),order.end(),[&](ll x,ll y){return w[x] < w[y];});
    ll sum_L,sum_R;
    sum_L=sum_R=0;
    for (ll i = 0;i < n;i ++){
        sum_L += w[order[i]];
        sum_R += w[order[n-1-i]];
//        cout<<sum_L<<' '<<sum_R<<endl;
        if (sum_L > u || sum_R < l)continue;
        vector <int> res;
        if (l <= sum_L && sum_L <= u){
            for (ll j = 0;j <= i;j ++)res.push_back(order[j]);
        }
        else if (l <= sum_R && sum_R <= u){
            for (ll j = n - i - 1;j < n;j ++)res.push_back(order[j]);
        }
        else{
            for (ll j = 0;j <= i;j ++)res.push_back(order[j]);
            ll sum = sum_L;
            ll last = n;
            for (ll j = i;j >= 0;j --){
                sum += w[n-1-i+j] - w[res[j]];
                res[j] = n-1-i+j;
                if (sum >= l){
                    break;
                }
            }
        }
        return res;
    }
    return std::vector<int>(0);
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:36:16: warning: unused variable 'last' [-Wunused-variable]
   36 |             ll last = 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...