Submission #49477

# Submission time Handle Problem Language Result Execution time Memory
49477 2018-05-29T11:42:14 Z Mamnoon_Siam Detecting Molecules (IOI16_molecules) C++17
31 / 100
1000 ms 25980 KB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};

const int maxn = 10005;

bitset<maxn> dp[maxn], vis[maxn];
int a[maxn], l, n, u;

int get(int i, int v) {
	if(l <= v and v <= u) return 1;
	if(v > u or i == n) return 0;
	if(vis[i][v]) return dp[i][v];
	vis[i][v] = 1;
	dp[i][v] = get(i + 1, v) | get(i + 1, v + a[i]);
	return dp[i][v];
}

void fill(int i, int v, vector<int> &ret) {
	if(l <= v and v <= u) {
		return;
	}
	assert(i < n);
	if(get(i + 1, v)) {
		fill(i + 1, v, ret);
	} else {
		ret.push_back(i);
		fill(i + 1, v + a[i], ret);
	}
}

vector<int> find_subset(int L, int U, vector<int> w) {
    n = w.size(), l = L, u = U;
    for(int i=0; i<n; i++)
    	a[i] = w[i];
    MEMSET(dp, -1);
    if(get(0, 0)) {
    	vector<int> ret;
    	fill(0, 0, ret);
    	return ret;
    }
    else {
    	return vector<int>();
    }
}

Compilation message

molecules.cpp: In function 'int myrand(int, int)':
molecules.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
  ^~
molecules.cpp:17:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
                          ^~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB OK (n = 1, answer = NO)
2 Correct 10 ms 12644 KB OK (n = 1, answer = NO)
3 Correct 10 ms 12720 KB OK (n = 1, answer = YES)
4 Correct 11 ms 12796 KB OK (n = 2, answer = YES)
5 Correct 14 ms 12828 KB OK (n = 2, answer = YES)
6 Correct 11 ms 12828 KB OK (n = 3, answer = YES)
7 Correct 11 ms 12908 KB OK (n = 3, answer = YES)
8 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
9 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
10 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
11 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
12 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
13 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
14 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
15 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
16 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
17 Correct 12 ms 13036 KB OK (n = 3, answer = NO)
18 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
19 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
2 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
3 Correct 11 ms 13052 KB OK (n = 12, answer = NO)
4 Correct 13 ms 13052 KB OK (n = 12, answer = NO)
5 Correct 14 ms 13052 KB OK (n = 12, answer = YES)
6 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
7 Correct 11 ms 13052 KB OK (n = 12, answer = YES)
8 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
9 Correct 12 ms 13052 KB OK (n = 6, answer = YES)
10 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
11 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
12 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
13 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
14 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
15 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
16 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
17 Correct 10 ms 13052 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB OK (n = 1, answer = NO)
2 Correct 10 ms 12644 KB OK (n = 1, answer = NO)
3 Correct 10 ms 12720 KB OK (n = 1, answer = YES)
4 Correct 11 ms 12796 KB OK (n = 2, answer = YES)
5 Correct 14 ms 12828 KB OK (n = 2, answer = YES)
6 Correct 11 ms 12828 KB OK (n = 3, answer = YES)
7 Correct 11 ms 12908 KB OK (n = 3, answer = YES)
8 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
9 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
10 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
11 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
12 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
13 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
14 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
15 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
16 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
17 Correct 12 ms 13036 KB OK (n = 3, answer = NO)
18 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
19 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
20 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
21 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
22 Correct 11 ms 13052 KB OK (n = 12, answer = NO)
23 Correct 13 ms 13052 KB OK (n = 12, answer = NO)
24 Correct 14 ms 13052 KB OK (n = 12, answer = YES)
25 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
26 Correct 11 ms 13052 KB OK (n = 12, answer = YES)
27 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
28 Correct 12 ms 13052 KB OK (n = 6, answer = YES)
29 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
30 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
31 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
32 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
33 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
34 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
35 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
36 Correct 10 ms 13052 KB OK (n = 100, answer = YES)
37 Correct 10 ms 13052 KB OK (n = 28, answer = YES)
38 Correct 11 ms 13052 KB OK (n = 27, answer = YES)
39 Correct 11 ms 13052 KB OK (n = 90, answer = YES)
40 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
41 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
42 Correct 12 ms 13052 KB OK (n = 10, answer = YES)
43 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
44 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
45 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
46 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
47 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
48 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
49 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
50 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
51 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
52 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
53 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
54 Correct 14 ms 13052 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB OK (n = 1, answer = NO)
2 Correct 10 ms 12644 KB OK (n = 1, answer = NO)
3 Correct 10 ms 12720 KB OK (n = 1, answer = YES)
4 Correct 11 ms 12796 KB OK (n = 2, answer = YES)
5 Correct 14 ms 12828 KB OK (n = 2, answer = YES)
6 Correct 11 ms 12828 KB OK (n = 3, answer = YES)
7 Correct 11 ms 12908 KB OK (n = 3, answer = YES)
8 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
9 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
10 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
11 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
12 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
13 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
14 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
15 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
16 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
17 Correct 12 ms 13036 KB OK (n = 3, answer = NO)
18 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
19 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
20 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
21 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
22 Correct 11 ms 13052 KB OK (n = 12, answer = NO)
23 Correct 13 ms 13052 KB OK (n = 12, answer = NO)
24 Correct 14 ms 13052 KB OK (n = 12, answer = YES)
25 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
26 Correct 11 ms 13052 KB OK (n = 12, answer = YES)
27 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
28 Correct 12 ms 13052 KB OK (n = 6, answer = YES)
29 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
30 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
31 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
32 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
33 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
34 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
35 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
36 Correct 10 ms 13052 KB OK (n = 100, answer = YES)
37 Correct 10 ms 13052 KB OK (n = 28, answer = YES)
38 Correct 11 ms 13052 KB OK (n = 27, answer = YES)
39 Correct 11 ms 13052 KB OK (n = 90, answer = YES)
40 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
41 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
42 Correct 12 ms 13052 KB OK (n = 10, answer = YES)
43 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
44 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
45 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
46 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
47 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
48 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
49 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
50 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
51 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
52 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
53 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
54 Correct 14 ms 13052 KB OK (n = 100, answer = YES)
55 Execution timed out 1088 ms 25980 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB OK (n = 1, answer = NO)
2 Correct 10 ms 12644 KB OK (n = 1, answer = NO)
3 Correct 10 ms 12720 KB OK (n = 1, answer = YES)
4 Correct 11 ms 12796 KB OK (n = 2, answer = YES)
5 Correct 14 ms 12828 KB OK (n = 2, answer = YES)
6 Correct 11 ms 12828 KB OK (n = 3, answer = YES)
7 Correct 11 ms 12908 KB OK (n = 3, answer = YES)
8 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
9 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
10 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
11 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
12 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
13 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
14 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
15 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
16 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
17 Correct 12 ms 13036 KB OK (n = 3, answer = NO)
18 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
19 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
20 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
21 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
22 Correct 11 ms 13052 KB OK (n = 12, answer = NO)
23 Correct 13 ms 13052 KB OK (n = 12, answer = NO)
24 Correct 14 ms 13052 KB OK (n = 12, answer = YES)
25 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
26 Correct 11 ms 13052 KB OK (n = 12, answer = YES)
27 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
28 Correct 12 ms 13052 KB OK (n = 6, answer = YES)
29 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
30 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
31 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
32 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
33 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
34 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
35 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
36 Correct 10 ms 13052 KB OK (n = 100, answer = YES)
37 Correct 10 ms 13052 KB OK (n = 28, answer = YES)
38 Correct 11 ms 13052 KB OK (n = 27, answer = YES)
39 Correct 11 ms 13052 KB OK (n = 90, answer = YES)
40 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
41 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
42 Correct 12 ms 13052 KB OK (n = 10, answer = YES)
43 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
44 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
45 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
46 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
47 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
48 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
49 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
50 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
51 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
52 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
53 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
54 Correct 14 ms 13052 KB OK (n = 100, answer = YES)
55 Execution timed out 1088 ms 25980 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB OK (n = 1, answer = NO)
2 Correct 10 ms 12644 KB OK (n = 1, answer = NO)
3 Correct 10 ms 12720 KB OK (n = 1, answer = YES)
4 Correct 11 ms 12796 KB OK (n = 2, answer = YES)
5 Correct 14 ms 12828 KB OK (n = 2, answer = YES)
6 Correct 11 ms 12828 KB OK (n = 3, answer = YES)
7 Correct 11 ms 12908 KB OK (n = 3, answer = YES)
8 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
9 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
10 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
11 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
12 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
13 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
14 Correct 11 ms 13036 KB OK (n = 3, answer = YES)
15 Correct 10 ms 13036 KB OK (n = 3, answer = YES)
16 Correct 10 ms 13036 KB OK (n = 3, answer = NO)
17 Correct 12 ms 13036 KB OK (n = 3, answer = NO)
18 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
19 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
20 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
21 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
22 Correct 11 ms 13052 KB OK (n = 12, answer = NO)
23 Correct 13 ms 13052 KB OK (n = 12, answer = NO)
24 Correct 14 ms 13052 KB OK (n = 12, answer = YES)
25 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
26 Correct 11 ms 13052 KB OK (n = 12, answer = YES)
27 Correct 12 ms 13052 KB OK (n = 12, answer = YES)
28 Correct 12 ms 13052 KB OK (n = 6, answer = YES)
29 Correct 13 ms 13052 KB OK (n = 12, answer = YES)
30 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
31 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
32 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
33 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
34 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
35 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
36 Correct 10 ms 13052 KB OK (n = 100, answer = YES)
37 Correct 10 ms 13052 KB OK (n = 28, answer = YES)
38 Correct 11 ms 13052 KB OK (n = 27, answer = YES)
39 Correct 11 ms 13052 KB OK (n = 90, answer = YES)
40 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
41 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
42 Correct 12 ms 13052 KB OK (n = 10, answer = YES)
43 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
44 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
45 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
46 Correct 11 ms 13052 KB OK (n = 100, answer = YES)
47 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
48 Correct 11 ms 13052 KB OK (n = 100, answer = NO)
49 Correct 12 ms 13052 KB OK (n = 100, answer = NO)
50 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
51 Correct 13 ms 13052 KB OK (n = 100, answer = YES)
52 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
53 Correct 12 ms 13052 KB OK (n = 100, answer = YES)
54 Correct 14 ms 13052 KB OK (n = 100, answer = YES)
55 Execution timed out 1088 ms 25980 KB Time limit exceeded
56 Halted 0 ms 0 KB -