Submission #1139750

#TimeUsernameProblemLanguageResultExecution timeMemory
1139750AmirMakaMDetecting Molecules (IOI16_molecules)C++20
100 / 100
34 ms3656 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define ull unsigned long long #define ll long long #define ld long double #define pb push_back #define f first #define s second #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define pdd pair<double,double> #define mp make_pair #define AmirMakaM ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) // solve it const ull SEED = chrono::steady_clock::now().time_since_epoch().count(); mt19937_64 mrand(SEED); ull rnd(ull x = ~(0ull)) {return mrand() % x;} const ll MOD = 998244353; const ll INF = 1e16+20; const int inf = 1e9 + 7; const ll N = 1e4+5; const ll M = 2e3+1; const double pi = 2*acos(0.0); const int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1}; vector<int> find_subset(int l, int r, vector<int> w) { int n = sz(w); vector<pii> a(n); for(int i=0; i<n; i++) { a[i] = {w[i],i}; } sort(all(a)); int j = -1; ll sum = 0; for(int i=0; i<n; i++) { if(j<i) j = i, sum = a[i].f; while(sum<l && j+1<n) { j++, sum += a[j].f; } if(l<=sum && sum<=r) { vector<int> ans; for(int t=i; t<=j; t++) ans.pb(a[t].s); return ans; } sum -= a[i].f; } return {}; }

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...