제출 #328232

#제출 시각아이디문제언어결과실행 시간메모리
328232arwaeystoamnegDetecting Molecules (IOI16_molecules)C++17
19 / 100
1 ms512 KiB
#include "molecules.h" #include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> #include<chrono> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; // warning: ld is rougly 2x slower than double. Proof: ld: https://oj.uz/submission/319677 double: https://oj.uz/submission/319678 typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pair<int, int>> vpi; typedef vector<pair<ll, ll>> vpll; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define mp make_pair #define rsz resize #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define f first #define s second #define endl '\n' #define test int testc;cin>>testc;while(testc--) const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; // for every grid problem!! const ll linf = 4000000000000000000LL; const ll inf = 1000000007;//998244353 const ld pi = 3.1415926535; void pv(vi a) { trav(x, a)cout << x << " "; cout << endl; }void pv(vll a) { trav(x, a)cout << x << " "; cout << endl; }void pv(vector<vi>a) { F0R(i, sz(a)) { cout << i << endl; pv(a[i]); cout << endl; } }void pv(vector<vll>a) { F0R(i, sz(a)) { cout << i << endl; pv(a[i]); }cout << endl; }void pv(vector<string>a) { trav(x, a)cout << x << endl; cout << endl; } vi find_subset(int l, int r, vi w) { int n = w.size(); vpi a(n); F0R(i, n)a[i] = { w[i],i }; sort(all(a)); ll prefix = 0, suffix = 0; F0R(i, n) { if (prefix >= l && prefix <= r) { vi ans; F0R(j, i) { ans.pb(a[j].s); } return ans; } else if (suffix >= l && suffix <= r) { vi ans; F0R(j, i) { ans.pb(a[n - j - 1].s); } return ans; } else { if (prefix > r && suffix > r) { vi ans(0); return ans; } if (prefix < l && suffix > r) { deque<int>b; F0R(j, i)b.pb(a[n - j - 1].s); int low = n - i - 1, high = n - 1; while (suffix > r) { suffix -= a[high--].f; suffix += a[low].f; b.pb(low--); b.pop_front(); } vi ans; trav(x, b)ans.pb(x); return ans; } } prefix += a[i].f; suffix += a[n - i - 1].f; } int i = n; if (prefix >= l && prefix <= r) { vi ans; F0R(j, i) { ans.pb(a[j].s); } return ans; } else if (suffix >= l && suffix <= r) { vi ans; F0R(j, i) { ans.pb(a[n - j - 1].s); } return ans; } else { if (prefix > r && suffix > r) { vi ans(0); return ans; } if (prefix < l && suffix > r) { deque<int>b; F0R(j, i)b.pb(a[n - j - 1].s); int low = n - i - 1, high = n - 1; while (suffix > r) { suffix -= a[high--].f; suffix += a[low].f; b.pb(low--); b.pop_front(); } vi ans; trav(x, b)ans.pb(x); return ans; } } vi ans(0); return ans; }
#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...