Submission #372589

#TimeUsernameProblemLanguageResultExecution timeMemory
372589cpp219Detecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms384 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 2e5 + 9; const ll mod = 1e9 + 7; vector<int> kq; void Get_kq(deque<ll> &dq){ for (auto i : dq) kq.push_back(i); } vector<int> find_subset(int L,int R, vector<int> w){ deque<ll> ans; vector<LL> a; ll cur = 0; ll n = w.size(); for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end()); if (R < a[0].fs) return kq; if (L <= a[0].fs&&a[0].fs <= R){ kq.push_back(a[0].sc); return kq; } if (L <= a[n - 1].fs&&a[n - 1].fs <= R){ kq.push_back(a[n - 1].sc); return kq; } //cout<<a[0].fs; exit(0); for (ll i = 0;i < n;i++){ if (L <= cur&&cur <= R) break; else if (cur + a[i].fs <= R) cur += a[i].fs,ans.push_back(a[i].sc); else if (cur + a[i].fs > R){ while(i < n){ if (L <= cur&&cur <= R){ Get_kq(ans); return kq; } if (ans.empty()) break; ll p = ans.front(); ans.pop_front(); ll val = a[i].fs - w[p]; if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++; } return kq; } } if (L <= cur&&cur <= R) Get_kq(ans); return kq; } /* int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "test" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } ll L,R,n,x; vector<int> w; cin>>n>>L>>R; for (ll i = 1;i <= n;i++) cin>>x,w.push_back(x); vector<int> c = find_subset(L,R,w); //return 0; for (auto i : c) cout<<i<<" "; } */

Compilation message (stderr)

molecules.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
molecules.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |     for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end());
      |     ^~~
molecules.cpp:24:53: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |     for (ll i = 0;i < n;i++) a.push_back({w[i],i}); sort(a.begin(),a.end());
      |                                                     ^~~~
molecules.cpp:44:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   44 |                 if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++;
      |                 ^~
molecules.cpp:44:72: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   44 |                 if (cur + val <= R) cur += val,ans.push_back(a[i].sc); i++;
      |                                                                        ^
#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...