답안 #124279

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124279 2019-07-02T23:41:23 Z tutis Mountains (IOI17_mountains) C++17
70 / 100
1000 ms 3088 KB
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
struct BitSet
{
	unsigned long long A[32];
	unsigned long long h;
	BitSet()
	{
		h = 0;
		fill_n(A, 32, 0ull);
	}
	bool operator<(const BitSet& o)const
	{
		if (h != o.h)
			return h < o.h;
		for (int i = 0; i < 32; i++)
		{
			if (A[i] != o.A[i])
				return A[i] < o.A[i];
		}
		return false;
	}
	void set(int i)
	{
		for (int t = 0; t < 32; t++)
		{
			if (i < 64)
			{
				h ^= A[t];
				A[t] |= (1ull << i);
				h ^= A[t];
				return;
			}
			else
			{
				i -= 64;
			}
		}
	}
	void unset(int i)
	{
		for (int t = 0; t < 32; t++)
		{
			if (i < 64)
			{
				h ^= A[t];
				A[t] &= (~(1ull << i));
				h ^= A[t];
				return;
			}
			else
			{
				i -= 64;
			}
		}
	}
	void andas(BitSet &o)
	{
		h = 0;
		for (int t = 0; t < 32; t++)
		{
			A[t] &= o.A[t];
			h ^= A[t];
		}
	}
	int First()
	{
		int ret = 0;
		for (int t = 0; t < 32; t++)
		{
			if (A[t] == 0)
			{
				ret += 64;
			}
			else
			{
				return ret + __builtin_ctzll(A[t]);
			}
		}
		return ret;
	}
};
BitSet ok[2000];
int sz[2000];
map<BitSet, int>M;
int dp(BitSet x)
{
	int &ans = M[x];
	if (ans != 0)
		return ans;
	int i = x.First();
	while (i < 2000)
	{
		x.unset(i);
		BitSet y = x;
		y.andas(ok[i]);
		ans = max(ans, 1 + dp(y));
		i = x.First();
	}
	return ans;
}
int maximum_deevs(vector<int> y)
{
	BitSet deevs;
	for (ll i = 0; i < (ll)y.size(); i++)
	{
		ll k = i + 1;
		for (ll j = i + 1; j < (ll)y.size(); j++)
		{
			if ((y[j] - y[i]) * (k - i) >= (y[k] - y[i]) * (j - i))
				k = j;
			if (k != j)
			{
				ok[i].set(j);
				sz[i]++;
			}
		}
		deevs.set(i);
	}
	return dp(deevs);
}/*
int main()
{
	cout << maximum_deevs({ 6, 1, 5, 2, 3, 1}) << endl;//3
	cout << maximum_deevs({ 0, 1, 2}) << endl;//1
}/**/

Compilation message

mountains.cpp:129:2: warning: "/*" within comment [-Wcomment]
 }/**/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 2 ms 892 KB Output is correct
3 Correct 2 ms 888 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 888 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 2 ms 888 KB Output is correct
11 Correct 2 ms 888 KB Output is correct
12 Correct 2 ms 888 KB Output is correct
13 Correct 2 ms 888 KB Output is correct
14 Correct 2 ms 888 KB Output is correct
15 Correct 2 ms 888 KB Output is correct
16 Correct 2 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 2 ms 892 KB Output is correct
3 Correct 2 ms 888 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 888 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 2 ms 888 KB Output is correct
11 Correct 2 ms 888 KB Output is correct
12 Correct 2 ms 888 KB Output is correct
13 Correct 2 ms 888 KB Output is correct
14 Correct 2 ms 888 KB Output is correct
15 Correct 2 ms 888 KB Output is correct
16 Correct 2 ms 888 KB Output is correct
17 Correct 2 ms 888 KB Output is correct
18 Correct 2 ms 888 KB Output is correct
19 Correct 2 ms 888 KB Output is correct
20 Correct 2 ms 888 KB Output is correct
21 Correct 2 ms 888 KB Output is correct
22 Correct 2 ms 888 KB Output is correct
23 Correct 2 ms 888 KB Output is correct
24 Correct 2 ms 888 KB Output is correct
25 Correct 2 ms 888 KB Output is correct
26 Correct 2 ms 888 KB Output is correct
27 Correct 2 ms 888 KB Output is correct
28 Correct 2 ms 888 KB Output is correct
29 Correct 2 ms 888 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 888 KB Output is correct
32 Correct 2 ms 888 KB Output is correct
33 Correct 2 ms 888 KB Output is correct
34 Correct 2 ms 888 KB Output is correct
35 Correct 2 ms 888 KB Output is correct
36 Correct 2 ms 888 KB Output is correct
37 Correct 3 ms 888 KB Output is correct
38 Correct 2 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 2 ms 892 KB Output is correct
3 Correct 2 ms 888 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 888 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 2 ms 888 KB Output is correct
11 Correct 2 ms 888 KB Output is correct
12 Correct 2 ms 888 KB Output is correct
13 Correct 2 ms 888 KB Output is correct
14 Correct 2 ms 888 KB Output is correct
15 Correct 2 ms 888 KB Output is correct
16 Correct 2 ms 888 KB Output is correct
17 Correct 2 ms 888 KB Output is correct
18 Correct 2 ms 888 KB Output is correct
19 Correct 2 ms 888 KB Output is correct
20 Correct 2 ms 888 KB Output is correct
21 Correct 2 ms 888 KB Output is correct
22 Correct 2 ms 888 KB Output is correct
23 Correct 2 ms 888 KB Output is correct
24 Correct 2 ms 888 KB Output is correct
25 Correct 2 ms 888 KB Output is correct
26 Correct 2 ms 888 KB Output is correct
27 Correct 2 ms 888 KB Output is correct
28 Correct 2 ms 888 KB Output is correct
29 Correct 2 ms 888 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 888 KB Output is correct
32 Correct 2 ms 888 KB Output is correct
33 Correct 2 ms 888 KB Output is correct
34 Correct 2 ms 888 KB Output is correct
35 Correct 2 ms 888 KB Output is correct
36 Correct 2 ms 888 KB Output is correct
37 Correct 3 ms 888 KB Output is correct
38 Correct 2 ms 888 KB Output is correct
39 Correct 9 ms 1016 KB Output is correct
40 Correct 14 ms 1016 KB Output is correct
41 Correct 20 ms 1144 KB Output is correct
42 Correct 21 ms 1148 KB Output is correct
43 Correct 15 ms 1144 KB Output is correct
44 Correct 15 ms 1016 KB Output is correct
45 Correct 19 ms 1272 KB Output is correct
46 Correct 20 ms 1144 KB Output is correct
47 Correct 18 ms 1144 KB Output is correct
48 Correct 17 ms 1144 KB Output is correct
49 Correct 20 ms 1144 KB Output is correct
50 Correct 20 ms 1272 KB Output is correct
51 Correct 20 ms 1144 KB Output is correct
52 Correct 13 ms 1528 KB Output is correct
53 Correct 10 ms 1400 KB Output is correct
54 Correct 11 ms 1400 KB Output is correct
55 Correct 9 ms 1404 KB Output is correct
56 Correct 10 ms 1400 KB Output is correct
57 Correct 10 ms 1016 KB Output is correct
58 Correct 31 ms 1400 KB Output is correct
59 Correct 21 ms 1144 KB Output is correct
60 Correct 10 ms 1016 KB Output is correct
61 Correct 18 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 2 ms 892 KB Output is correct
3 Correct 2 ms 888 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 888 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 2 ms 888 KB Output is correct
11 Correct 2 ms 888 KB Output is correct
12 Correct 2 ms 888 KB Output is correct
13 Correct 2 ms 888 KB Output is correct
14 Correct 2 ms 888 KB Output is correct
15 Correct 2 ms 888 KB Output is correct
16 Correct 2 ms 888 KB Output is correct
17 Correct 2 ms 888 KB Output is correct
18 Correct 2 ms 888 KB Output is correct
19 Correct 2 ms 888 KB Output is correct
20 Correct 2 ms 888 KB Output is correct
21 Correct 2 ms 888 KB Output is correct
22 Correct 2 ms 888 KB Output is correct
23 Correct 2 ms 888 KB Output is correct
24 Correct 2 ms 888 KB Output is correct
25 Correct 2 ms 888 KB Output is correct
26 Correct 2 ms 888 KB Output is correct
27 Correct 2 ms 888 KB Output is correct
28 Correct 2 ms 888 KB Output is correct
29 Correct 2 ms 888 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 888 KB Output is correct
32 Correct 2 ms 888 KB Output is correct
33 Correct 2 ms 888 KB Output is correct
34 Correct 2 ms 888 KB Output is correct
35 Correct 2 ms 888 KB Output is correct
36 Correct 2 ms 888 KB Output is correct
37 Correct 3 ms 888 KB Output is correct
38 Correct 2 ms 888 KB Output is correct
39 Correct 9 ms 1016 KB Output is correct
40 Correct 14 ms 1016 KB Output is correct
41 Correct 20 ms 1144 KB Output is correct
42 Correct 21 ms 1148 KB Output is correct
43 Correct 15 ms 1144 KB Output is correct
44 Correct 15 ms 1016 KB Output is correct
45 Correct 19 ms 1272 KB Output is correct
46 Correct 20 ms 1144 KB Output is correct
47 Correct 18 ms 1144 KB Output is correct
48 Correct 17 ms 1144 KB Output is correct
49 Correct 20 ms 1144 KB Output is correct
50 Correct 20 ms 1272 KB Output is correct
51 Correct 20 ms 1144 KB Output is correct
52 Correct 13 ms 1528 KB Output is correct
53 Correct 10 ms 1400 KB Output is correct
54 Correct 11 ms 1400 KB Output is correct
55 Correct 9 ms 1404 KB Output is correct
56 Correct 10 ms 1400 KB Output is correct
57 Correct 10 ms 1016 KB Output is correct
58 Correct 31 ms 1400 KB Output is correct
59 Correct 21 ms 1144 KB Output is correct
60 Correct 10 ms 1016 KB Output is correct
61 Correct 18 ms 1144 KB Output is correct
62 Correct 326 ms 2040 KB Output is correct
63 Execution timed out 1081 ms 3088 KB Time limit exceeded
64 Halted 0 ms 0 KB -