Submission #49470

# Submission time Handle Problem Language Result Execution time Memory
49470 2018-05-29T08:38:14 Z Mamnoon_Siam Detecting Molecules (IOI16_molecules) C++17
31 / 100
25 ms 10168 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 = 1005;

int dp[maxn][maxn];
int a[maxn], l, n, u;

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

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 5 ms 4344 KB OK (n = 1, answer = NO)
2 Correct 5 ms 4580 KB OK (n = 1, answer = NO)
3 Correct 5 ms 4580 KB OK (n = 1, answer = YES)
4 Correct 5 ms 4580 KB OK (n = 2, answer = YES)
5 Correct 5 ms 4632 KB OK (n = 2, answer = YES)
6 Correct 5 ms 4632 KB OK (n = 3, answer = YES)
7 Correct 4 ms 4632 KB OK (n = 3, answer = YES)
8 Correct 5 ms 4736 KB OK (n = 3, answer = YES)
9 Correct 4 ms 4736 KB OK (n = 3, answer = YES)
10 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
11 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
12 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
13 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
14 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
15 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
16 Correct 7 ms 4800 KB OK (n = 3, answer = NO)
17 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
18 Correct 5 ms 4800 KB OK (n = 100, answer = NO)
19 Correct 6 ms 4800 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4800 KB OK (n = 12, answer = YES)
2 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
3 Correct 6 ms 4860 KB OK (n = 12, answer = NO)
4 Correct 5 ms 4860 KB OK (n = 12, answer = NO)
5 Correct 5 ms 4860 KB OK (n = 12, answer = YES)
6 Correct 6 ms 4860 KB OK (n = 12, answer = YES)
7 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
8 Correct 6 ms 4888 KB OK (n = 12, answer = YES)
9 Correct 5 ms 4888 KB OK (n = 6, answer = YES)
10 Correct 5 ms 4888 KB OK (n = 12, answer = YES)
11 Correct 6 ms 4888 KB OK (n = 100, answer = NO)
12 Correct 7 ms 4888 KB OK (n = 100, answer = YES)
13 Correct 5 ms 4888 KB OK (n = 100, answer = NO)
14 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
15 Correct 7 ms 4936 KB OK (n = 100, answer = YES)
16 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
17 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB OK (n = 1, answer = NO)
2 Correct 5 ms 4580 KB OK (n = 1, answer = NO)
3 Correct 5 ms 4580 KB OK (n = 1, answer = YES)
4 Correct 5 ms 4580 KB OK (n = 2, answer = YES)
5 Correct 5 ms 4632 KB OK (n = 2, answer = YES)
6 Correct 5 ms 4632 KB OK (n = 3, answer = YES)
7 Correct 4 ms 4632 KB OK (n = 3, answer = YES)
8 Correct 5 ms 4736 KB OK (n = 3, answer = YES)
9 Correct 4 ms 4736 KB OK (n = 3, answer = YES)
10 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
11 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
12 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
13 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
14 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
15 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
16 Correct 7 ms 4800 KB OK (n = 3, answer = NO)
17 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
18 Correct 5 ms 4800 KB OK (n = 100, answer = NO)
19 Correct 6 ms 4800 KB OK (n = 100, answer = YES)
20 Correct 6 ms 4800 KB OK (n = 12, answer = YES)
21 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
22 Correct 6 ms 4860 KB OK (n = 12, answer = NO)
23 Correct 5 ms 4860 KB OK (n = 12, answer = NO)
24 Correct 5 ms 4860 KB OK (n = 12, answer = YES)
25 Correct 6 ms 4860 KB OK (n = 12, answer = YES)
26 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
27 Correct 6 ms 4888 KB OK (n = 12, answer = YES)
28 Correct 5 ms 4888 KB OK (n = 6, answer = YES)
29 Correct 5 ms 4888 KB OK (n = 12, answer = YES)
30 Correct 6 ms 4888 KB OK (n = 100, answer = NO)
31 Correct 7 ms 4888 KB OK (n = 100, answer = YES)
32 Correct 5 ms 4888 KB OK (n = 100, answer = NO)
33 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
34 Correct 7 ms 4936 KB OK (n = 100, answer = YES)
35 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
36 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
37 Correct 6 ms 4936 KB OK (n = 28, answer = YES)
38 Correct 6 ms 4936 KB OK (n = 27, answer = YES)
39 Correct 6 ms 4936 KB OK (n = 90, answer = YES)
40 Correct 5 ms 4936 KB OK (n = 100, answer = YES)
41 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
42 Correct 6 ms 4936 KB OK (n = 10, answer = YES)
43 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
44 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
45 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
46 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
47 Correct 7 ms 4956 KB OK (n = 100, answer = NO)
48 Correct 5 ms 4956 KB OK (n = 100, answer = NO)
49 Correct 6 ms 4956 KB OK (n = 100, answer = NO)
50 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
51 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
52 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
53 Correct 5 ms 4956 KB OK (n = 100, answer = YES)
54 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB OK (n = 1, answer = NO)
2 Correct 5 ms 4580 KB OK (n = 1, answer = NO)
3 Correct 5 ms 4580 KB OK (n = 1, answer = YES)
4 Correct 5 ms 4580 KB OK (n = 2, answer = YES)
5 Correct 5 ms 4632 KB OK (n = 2, answer = YES)
6 Correct 5 ms 4632 KB OK (n = 3, answer = YES)
7 Correct 4 ms 4632 KB OK (n = 3, answer = YES)
8 Correct 5 ms 4736 KB OK (n = 3, answer = YES)
9 Correct 4 ms 4736 KB OK (n = 3, answer = YES)
10 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
11 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
12 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
13 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
14 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
15 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
16 Correct 7 ms 4800 KB OK (n = 3, answer = NO)
17 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
18 Correct 5 ms 4800 KB OK (n = 100, answer = NO)
19 Correct 6 ms 4800 KB OK (n = 100, answer = YES)
20 Correct 6 ms 4800 KB OK (n = 12, answer = YES)
21 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
22 Correct 6 ms 4860 KB OK (n = 12, answer = NO)
23 Correct 5 ms 4860 KB OK (n = 12, answer = NO)
24 Correct 5 ms 4860 KB OK (n = 12, answer = YES)
25 Correct 6 ms 4860 KB OK (n = 12, answer = YES)
26 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
27 Correct 6 ms 4888 KB OK (n = 12, answer = YES)
28 Correct 5 ms 4888 KB OK (n = 6, answer = YES)
29 Correct 5 ms 4888 KB OK (n = 12, answer = YES)
30 Correct 6 ms 4888 KB OK (n = 100, answer = NO)
31 Correct 7 ms 4888 KB OK (n = 100, answer = YES)
32 Correct 5 ms 4888 KB OK (n = 100, answer = NO)
33 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
34 Correct 7 ms 4936 KB OK (n = 100, answer = YES)
35 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
36 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
37 Correct 6 ms 4936 KB OK (n = 28, answer = YES)
38 Correct 6 ms 4936 KB OK (n = 27, answer = YES)
39 Correct 6 ms 4936 KB OK (n = 90, answer = YES)
40 Correct 5 ms 4936 KB OK (n = 100, answer = YES)
41 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
42 Correct 6 ms 4936 KB OK (n = 10, answer = YES)
43 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
44 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
45 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
46 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
47 Correct 7 ms 4956 KB OK (n = 100, answer = NO)
48 Correct 5 ms 4956 KB OK (n = 100, answer = NO)
49 Correct 6 ms 4956 KB OK (n = 100, answer = NO)
50 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
51 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
52 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
53 Correct 5 ms 4956 KB OK (n = 100, answer = YES)
54 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
55 Runtime error 25 ms 10168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB OK (n = 1, answer = NO)
2 Correct 5 ms 4580 KB OK (n = 1, answer = NO)
3 Correct 5 ms 4580 KB OK (n = 1, answer = YES)
4 Correct 5 ms 4580 KB OK (n = 2, answer = YES)
5 Correct 5 ms 4632 KB OK (n = 2, answer = YES)
6 Correct 5 ms 4632 KB OK (n = 3, answer = YES)
7 Correct 4 ms 4632 KB OK (n = 3, answer = YES)
8 Correct 5 ms 4736 KB OK (n = 3, answer = YES)
9 Correct 4 ms 4736 KB OK (n = 3, answer = YES)
10 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
11 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
12 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
13 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
14 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
15 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
16 Correct 7 ms 4800 KB OK (n = 3, answer = NO)
17 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
18 Correct 5 ms 4800 KB OK (n = 100, answer = NO)
19 Correct 6 ms 4800 KB OK (n = 100, answer = YES)
20 Correct 6 ms 4800 KB OK (n = 12, answer = YES)
21 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
22 Correct 6 ms 4860 KB OK (n = 12, answer = NO)
23 Correct 5 ms 4860 KB OK (n = 12, answer = NO)
24 Correct 5 ms 4860 KB OK (n = 12, answer = YES)
25 Correct 6 ms 4860 KB OK (n = 12, answer = YES)
26 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
27 Correct 6 ms 4888 KB OK (n = 12, answer = YES)
28 Correct 5 ms 4888 KB OK (n = 6, answer = YES)
29 Correct 5 ms 4888 KB OK (n = 12, answer = YES)
30 Correct 6 ms 4888 KB OK (n = 100, answer = NO)
31 Correct 7 ms 4888 KB OK (n = 100, answer = YES)
32 Correct 5 ms 4888 KB OK (n = 100, answer = NO)
33 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
34 Correct 7 ms 4936 KB OK (n = 100, answer = YES)
35 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
36 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
37 Correct 6 ms 4936 KB OK (n = 28, answer = YES)
38 Correct 6 ms 4936 KB OK (n = 27, answer = YES)
39 Correct 6 ms 4936 KB OK (n = 90, answer = YES)
40 Correct 5 ms 4936 KB OK (n = 100, answer = YES)
41 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
42 Correct 6 ms 4936 KB OK (n = 10, answer = YES)
43 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
44 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
45 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
46 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
47 Correct 7 ms 4956 KB OK (n = 100, answer = NO)
48 Correct 5 ms 4956 KB OK (n = 100, answer = NO)
49 Correct 6 ms 4956 KB OK (n = 100, answer = NO)
50 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
51 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
52 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
53 Correct 5 ms 4956 KB OK (n = 100, answer = YES)
54 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
55 Runtime error 25 ms 10168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4344 KB OK (n = 1, answer = NO)
2 Correct 5 ms 4580 KB OK (n = 1, answer = NO)
3 Correct 5 ms 4580 KB OK (n = 1, answer = YES)
4 Correct 5 ms 4580 KB OK (n = 2, answer = YES)
5 Correct 5 ms 4632 KB OK (n = 2, answer = YES)
6 Correct 5 ms 4632 KB OK (n = 3, answer = YES)
7 Correct 4 ms 4632 KB OK (n = 3, answer = YES)
8 Correct 5 ms 4736 KB OK (n = 3, answer = YES)
9 Correct 4 ms 4736 KB OK (n = 3, answer = YES)
10 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
11 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
12 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
13 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
14 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
15 Correct 5 ms 4800 KB OK (n = 3, answer = YES)
16 Correct 7 ms 4800 KB OK (n = 3, answer = NO)
17 Correct 5 ms 4800 KB OK (n = 3, answer = NO)
18 Correct 5 ms 4800 KB OK (n = 100, answer = NO)
19 Correct 6 ms 4800 KB OK (n = 100, answer = YES)
20 Correct 6 ms 4800 KB OK (n = 12, answer = YES)
21 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
22 Correct 6 ms 4860 KB OK (n = 12, answer = NO)
23 Correct 5 ms 4860 KB OK (n = 12, answer = NO)
24 Correct 5 ms 4860 KB OK (n = 12, answer = YES)
25 Correct 6 ms 4860 KB OK (n = 12, answer = YES)
26 Correct 7 ms 4860 KB OK (n = 12, answer = YES)
27 Correct 6 ms 4888 KB OK (n = 12, answer = YES)
28 Correct 5 ms 4888 KB OK (n = 6, answer = YES)
29 Correct 5 ms 4888 KB OK (n = 12, answer = YES)
30 Correct 6 ms 4888 KB OK (n = 100, answer = NO)
31 Correct 7 ms 4888 KB OK (n = 100, answer = YES)
32 Correct 5 ms 4888 KB OK (n = 100, answer = NO)
33 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
34 Correct 7 ms 4936 KB OK (n = 100, answer = YES)
35 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
36 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
37 Correct 6 ms 4936 KB OK (n = 28, answer = YES)
38 Correct 6 ms 4936 KB OK (n = 27, answer = YES)
39 Correct 6 ms 4936 KB OK (n = 90, answer = YES)
40 Correct 5 ms 4936 KB OK (n = 100, answer = YES)
41 Correct 6 ms 4936 KB OK (n = 100, answer = YES)
42 Correct 6 ms 4936 KB OK (n = 10, answer = YES)
43 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
44 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
45 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
46 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
47 Correct 7 ms 4956 KB OK (n = 100, answer = NO)
48 Correct 5 ms 4956 KB OK (n = 100, answer = NO)
49 Correct 6 ms 4956 KB OK (n = 100, answer = NO)
50 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
51 Correct 7 ms 4956 KB OK (n = 100, answer = YES)
52 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
53 Correct 5 ms 4956 KB OK (n = 100, answer = YES)
54 Correct 6 ms 4956 KB OK (n = 100, answer = YES)
55 Runtime error 25 ms 10168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
56 Halted 0 ms 0 KB -