【游记】CSP J/S 2019 游记

J 组

\(2:30\)开始, \(2:13\)还在酒店的我看了看手表。。。飞奔考场。

T1 数字游戏

秒切。

下午某中学某大佬说可用线性基(%)

T2 公交换乘

用单调队列思想,秒切。

T3 纪念品

刚看题,wow这不水题吗,铁定\(DP\),再看,嗯?啥时候买?啥时候卖?。。。后来发现可用背包,感觉正解,样例2没过。。。

考场代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;

const int N = 110;
 
int t, n;
ll m, ans;
ll a[N][N];
bool f[200010];
ll  b[200010][N];

int main()
{
	freopen("souvenir.in", "r", stdin);
	freopen("souvenir.out", "w", stdout);
	scanf("%d%d%lld", &t, &n, &m);
	for (int i = 1; i <= t; i++)
		for (int j = 1; j <= n; j++)
			scanf("%lld", &a[i][j]);
	for (int i = 1; i < t; i++)
	{
		memset(f, 0, sizeof(f));
		memset(b, 0, sizeof(b));
		f[0] = 1;
		for (int j = 1; j <= n; j++)
		{
			if(a[i][j] < a[i + 1][j])
			{
				for (int k = a[i][j]; k <= m; k++)
				{
					f[k] = f[k] || f[k - a[i][j]];
					if(f[k - a[i][j]])
						b[k][j] += b[k - a[i][j]][j] + 1;
				}
			}
		}
		ll plu = -22222;
		for (int j = m; j > 0; j--)
		{
			if(f[j])
			{
				plu = m - j;
				for (int k = 1; k <= n; k++)
					if(b[j][k])
					plu += m / (b[j][k] * a[i][k]) * (b[j][k] * a[i + 1][k]);
				break;
			}
		}
		if(plu != -22222)m = plu;
	}
	printf("%lld", m);
	return 0;
}

正解:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;

const int N = 110;
 
int t, n;
ll m, ans;
ll a[N][N];
ll f[200010];

int main()
{
	freopen("souvenir.in", "r", stdin);
	freopen("souvenir.out", "w", stdout);
	scanf("%d%d%lld", &t, &n, &m);
	for (int i = 1; i <= t; i++)
		for (int j = 1; j <= n; j++)
			scanf("%lld", &a[i][j]);
	for (int i = 1; i < t; i++)
	{
		memset(f, 0, sizeof(f));
		
		for (int j = 1; j <= n; j++)
		{
			for (int k = a[i][j]; k <= m; k++)
			{
				f[k] = max(f[k], f[k - a[i][j]] + a[i + 1][j] - a[i][j]);
			}
		}
		m = max(m, f[m] + m);
	}
	printf("%lld", m);
	return 0;
}

。。。

我枯了

T4 加工零件

考场想到了最短路,但发现不对劲,打了个\(\texttt{BFS}\)暴力。

正解:最短路

。。。

S组

Day0

\(\text{上午:}\)学校运动会,偷溜至机房。
\(\text{下午:}\)去广州

Day1

T1

\[\Large\text{十年OI一场空,不开unsigned见祖宗} \]

posted @ 2019-11-27 17:17  Jayun  阅读(201)  评论(1编辑  收藏  举报