제출 #841067

#제출 시각아이디문제언어결과실행 시간메모리
841067manhlinh1501Detecting Molecules (IOI16_molecules)C++17
100 / 100
45 ms8500 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; using pii = pair<int,int>; using pli = pair<i64,int>; #define sz(a) (int)a.size() #define eb emplace_back #define all(a) a.begin(),a.end() int search(int first,int second,int k,vector<pli> &a){ int l=first,r=second; int pos=-1; while(l<=r){ int m=l+r>>1; if(a[m].first-a[first-1].first>=k){ pos=m; r=m-1; } else l=m+1; } return pos; } vector<int> find_subset(int l, int r, vector<int> a){ int n = sz(a); vector<pii> res; for(int i=0;i<n;i++) res.eb(a[i],i); sort(all(res)); vector<pli> sum(n+1,{0,0}); for(int i=0;i<n;i++){ sum[i+1].first=sum[i].first+res[i].first; sum[i+1].second=res[i].second; } vector<int> ans; for(int i=1;i<=n;i++){ // for(int j=i;j<=n;j++){ // i64 res=sum[j].first-sum[i-1].first; // if(l<=res and res<=r){ // for(int k=i;k<=j;k++) // ans.eb(sum[k].second); // sort(all(ans)); // return ans; // } // } int pos=search(i,n,l,sum); if(pos==-1) continue; if(sum[pos].first-sum[i-1].first<=r){ // for(int j=i;j<=pos;j++) // cout<<sum[j].second<<" "; // cout<<"\n"; for(int j=i;j<=pos;j++) ans.eb(sum[j].second); break; } } sort(all(ans)); return ans; }

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

molecules.cpp: In function 'int search(int, int, int, std::vector<std::pair<long long int, int> >&)':
molecules.cpp:14:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   14 |   int m=l+r>>1;
      |         ~^~
#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...