제출 #729009

#제출 시각아이디문제언어결과실행 시간메모리
729009groguDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms308 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({l-x,0}); if(it==s.begin()) continue; it--; ll cur = it->fi + x; last[i] = it->sc; s.insert({cur,i}); //ll l = i+1,r = n,mid,rez = -1; //cerr<<"i: "<<i<< " "<<cur<<endl; for(ll j = i+1;j<=n;j++){ if(cur+a[j].fi<=r&&cur+a[j].fi>=l){ vector<int> ans; ans.pb(a[j].sc); ll k = i; while(k){ ans.pb(a[k].sc); k = last[k]; } sort(all(ans)); return ans; } } } 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...