답안 #124256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124256 2019-07-02T22:23:55 Z tutis Mountains (IOI17_mountains) C++17
컴파일 오류
0 ms 0 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];
	BitSet()
	{
		fill_n(A, 32, 0ull);
	}
	bool operator<(const BitSet& o)const
	{
		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)
			{
				A[t] |= (1ull << i);
				return;
			}
			else
			{
				i -= 64;
			}
		}
	}
	void unset(int i)
	{
		for (int t = 0; t < 32; t++)
		{
			if (i < 64)
			{
				A[t] &= (~(1ull << i));
				return;
			}
			else
			{
				i -= 64;
			}
		}
	}
	void andas(BitSet &o)
	{
		for (int t = 0; t < 32; t++)
			A[t] &= o.A[t];
	}
	int First()
	{
		int ret = 0;
		for (int t = 0; t < 32; t++)
		{
			if (A[t] == 0)
			{
				ret += 64;
			}
			else
			{
				return ret + __builtin_ctz(A[t]);
			}
		}
		return ret;
	}
};
BitSet ok[2000];
map<BitSet, int>M;
int dp(BitSet x)
{
	int i = x.First();
	if (i >= 2000)
		return 0;
	int &ans = M[x];
	if (ans != 0)
		return ans;
	x.unset(i);
	ans = dp(x);
	x.andas(ok[i]);
	ans = max(ans, 1 + dp(x));
	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);
		}
		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

/tmp/cc4wdSoo.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccL2y70n.o:mountains.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status