Submission #490502

#TimeUsernameProblemLanguageResultExecution timeMemory
490502MohamedAliSaidaneDetecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<pld> vpd; #define pb push_back #define popb pop_back #define all(v) (v).begin(),(v).end() #define ff first #define ss second const ll MOD = 1e9 + 7; const ll INF = 1e18; int nx[4] = {1,-1,0,0}, ny[4] = {0,0,1,-1}; /////// SOLUTION \\\\\\\ vi find_subset(int l, int u, vi w) { vpi A; int n = w.size(); for(int i = 0; i <n; i ++) A.pb({w[i],i}); sort(all(A)); ll pref[n+1]; pref[0] = 0; for(int i= 0; i <n; i ++) pref[i+1] = pref[i] + A[i].ff; int left = 0; int right = -1; for(int k= 1; k <= n; k ++) { if(pref[k] > u || pref[n] - pref[n+1-k] <l ) continue; if(pref[k] >= l) { left = 0; right = k-1; break; } if(pref[n]-pref[n-k] <= u) { left = n-k; right = n-1; break; } if(pref[k] <= l && pref[n+1-k] >= u) { bool flag= false; for(int i = 0; i <= n-k; i ++) { ll sum = pref[i+k]-pref[i]; if(sum >= l && sum <= u) { left = i; right = i + k-1; flag= true; break; } } if(flag) break; } } vi res; for(int i = left; i <= right; i ++) res.pb(A[i].ss); return res; }

Compilation message (stderr)

molecules.cpp:27:1: warning: multi-line comment [-Wcomment]
   27 | /////// SOLUTION \\\\\\\
      | ^
#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...