#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, 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, 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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
388 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
364 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
364 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
364 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
364 KB |
OK (n = 100, answer = YES) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
item #6 is taken twice |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
388 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
364 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
364 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
364 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
364 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
364 KB |
item #6 is taken twice |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
388 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
364 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
364 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
364 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
364 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
364 KB |
item #6 is taken twice |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
388 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
364 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
364 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
364 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
364 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
364 KB |
item #6 is taken twice |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
388 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
364 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
1 ms |
364 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
364 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
364 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
1 ms |
364 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
0 ms |
364 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
1 ms |
364 KB |
OK (n = 100, answer = YES) |
20 |
Incorrect |
1 ms |
364 KB |
item #6 is taken twice |
21 |
Halted |
0 ms |
0 KB |
- |