// name = molecules_sk_random.cpp, type = cpp.g++11
#include "molecules.h"
/**
Author: Sergey Kopeliovich ([email protected])
Random walk
*/
#include <cstdio>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair <int, int> pii;
// return value: result if solution exists and empty vector otherwise
vector<int> find_subset( int l, int u, vector<int> w ) {
int n = w.size();
vector<pii> wp(n);
forn(i, n)
wp[i] = {w[i], i};
mt19937 rnd(239);
forn(_, 1000) {
shuffle(wp.begin(), wp.end(), rnd);
int sum = 0, i = 0;
while (i < n && sum < l)
sum += wp[i++].first;
if (l <= sum && sum <= u) {
vector<int> res(i);
forn(j, i)
res[j] = wp[j].second;
return res;
}
}
return vector<int>();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
3 ms |
1936 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
1936 KB |
OK (n = 100, answer = YES) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
5 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
6 |
Incorrect |
0 ms |
1936 KB |
Contestant can not find answer, jury can |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
3 ms |
1936 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
1936 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
25 |
Incorrect |
0 ms |
1936 KB |
Contestant can not find answer, jury can |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
3 ms |
1936 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
1936 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
25 |
Incorrect |
0 ms |
1936 KB |
Contestant can not find answer, jury can |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
3 ms |
1936 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
1936 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
25 |
Incorrect |
0 ms |
1936 KB |
Contestant can not find answer, jury can |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
0 ms |
1936 KB |
OK (n = 1, answer = YES) |
4 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
5 |
Correct |
0 ms |
1936 KB |
OK (n = 2, answer = YES) |
6 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
7 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
8 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
9 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
10 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
11 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
12 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
13 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
14 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
15 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = YES) |
16 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
17 |
Correct |
0 ms |
1936 KB |
OK (n = 3, answer = NO) |
18 |
Correct |
3 ms |
1936 KB |
OK (n = 100, answer = NO) |
19 |
Correct |
0 ms |
1936 KB |
OK (n = 100, answer = YES) |
20 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
21 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
22 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
23 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = NO) |
24 |
Correct |
0 ms |
1936 KB |
OK (n = 12, answer = YES) |
25 |
Incorrect |
0 ms |
1936 KB |
Contestant can not find answer, jury can |
26 |
Halted |
0 ms |
0 KB |
- |