제출 #729026

#제출 시각아이디문제언어결과실행 시간메모리
729026groguDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> #define endl '\n' #define here cerr<<"=========================================\n" #define dbg(x) cerr<<#x<<": "<<x<<endl; #define ll long long #define pb push_back #define popb pop_back #define all(a_) a_.begin(),a_.end() #define pll pair<ll,ll> #define sc second #define fi first using namespace std; #define maxn 200005 ll n; pll a[maxn]; ll last[maxn]; ll l,r; vector<int> find_subset(int L, int R, vector<int> w) { n = w.size(); l = L; r = R; for(ll i = 1;i<=n;i++){ a[i].fi = w[i-1]; a[i].sc = i-1; if(a[i].fi>=l&&a[i].fi<=r) return {i-1}; } sort(a+1,a+1+n); reverse(a+1,a+1+n); set<pll> s; s.insert({0,0}); for(ll i = 1;i<=n;i++){ ll x = a[i].fi; auto it = s.lower_bound({r-x,0}); if(it!=s.begin()){ it--; ll cur = it->fi + x; //cerr<<"i: "<<i<< " "<<cur<<endl; if(cur>=l){ last[i] = it->sc; ll k = i; vector<int> ans; while(k){ cur-=a[k].fi; if(cur<0) break; ans.pb(a[k].sc); k = last[k]; } sort(all(ans)); return ans; } last[i] = it->sc; s.insert({cur,i}); } s.insert({x,i}); } return {}; } /** 4 15 17 6 8 8 7 4 14 15 5 5 6 6 4 10 20 15 17 16 18 **/

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:45: warning: narrowing conversion of '(i - 1)' from 'long long int' to 'int' [-Wnarrowing]
   25 |         if(a[i].fi>=l&&a[i].fi<=r) return {i-1};
      |                                            ~^~
molecules.cpp:25:45: warning: narrowing conversion of '(i - 1)' from 'long long int' to 'int' [-Wnarrowing]
#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...