Submission #186989

#TimeUsernameProblemLanguageResultExecution timeMemory
186989PedroBigManDetecting Molecules (IOI16_molecules)C++14
100 / 100
81 ms17136 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <map> #include <set> #include <queue> #include <deque> #include "molecules.h" using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=a; i<b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define INF 100000000000000000LL ll insig; #define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);} void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;} vector<int> find_subset(int lll,int uuu, vector<int> wee) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll N=wee.size(); vector<pl> we; ll l=(ll) lll; ll u=(ll) uuu; ll curin; REP(i,0,N) {we.pb(mp((ll) wee[i],i));} sort(we.begin(),we.end()); vector<ll> w; REP(i,0,N) {w.pb(we[i].ff);} vector<bool> cur; REP(i,0,N) {cur.pb(false);} vector<pl> sums; ll losum=0; ll hisum=0; REP(i,0,N) { losum+=w[i]; hisum+=w[N-i-1]; sums.pb(mp(losum,hisum)); } vector<int> ans; REP(k,1,N+1) { if(sums[k-1].ff<=u && sums[k-1].ss>=l) { ll curs=0; REP(i,0,k) {cur[i]=true; curs+=w[i];} ll ind=0; while(curs<l) { cur[ind]=false; cur[N-1-ind]=true; curs-=w[ind]; curs+=w[N-1-ind]; ind++; } REP(i,0,N) {if(cur[i]) {ans.pb((int) we[i].ss);}} return ans; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'void Out(std::vector<long long int>)':
molecules.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
molecules.cpp:24:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
molecules.cpp:24:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:31:8: warning: unused variable 'curin' [-Wunused-variable]
     ll curin;
        ^~~~~
#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...