2014ACM/ICPC亚洲区鞍山赛区现场赛——题目重现

2014ACM/ICPC亚洲区鞍山赛区现场赛——题目重现

题目链接

5小时内就搞了5题B、C、D、E,I。

H题想到要打表搞了,可惜时间不够,后面打出表试了几下过了- -

K题过的人也比较多,感觉是个几何旋转+ploya,但是几何实在不行没什么想法

B:这题就是一个大模拟,直接数组去模拟即可,注意细节就能过

C:类似大白上一题红蓝三角形的, 每个数字找一个互质和一个不互质个数,除掉重复就直接除2,然后总的C(n, 3)减去即可,问题在怎么处理一个数字互质和不互质的,其实只要处理出不互质的即可,这步利用容斥原理去搞,每个数字分解成因子,然后计数因子个数,对于每个数而言,为f(1个质因子) - f(2个质因子) + f(3) - f(4) + ...,然后就可以统计出答案了

D:这题首先转化成n个数字去掉k个,惯性最小,那么其实重心的计算方法,就根据物理里面的杠杆原理(反正我是这样想的),由于质量都是1,所以等于所有距离累加起来,然后减去0,在除个数就是等于每个位置距离中心要减少的长度,那么推出公式∑(di?d平均值)2,其实这个就是方差了,问题就转化为n个数字去掉k个,使得方差最大,那么贪心知道越密集越好,所以肯定是连续的n
- k个,那么只要从左往右一遍扫过去不断维护即可

E:dp,dp[i][j]表示到第i个位置,在第j列,这样递推过去即可,也算比较水的一题

H:把竖的一列看成一个二进制数,每次就相当与选已有的两个二进制数,去构造一个新的二进制数,然后把这个数丢进已有的数组中,没想到好的办法,写个暴力,让他跑9步(这个跑了1分多钟,10步的话要跑好久啊),然后发现还有6个无解,全赋为10就wa了,然后试了一下,原来有一个解的答案是11,然后就过了- -

I:这题就是个签到题,不能多说

K:应该是几何旋转求出有几种方式,然后ploya定理求解

代码:

B:代码队友写的,留坑等会补

C:代码队友写的,留坑等会补

D:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 50005;
int t, n, k;
double a[N];

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%d%d", &n, &k);
		for (int i = 0; i < n; i++) scanf("%lf", &a[i]);
		if (n == k) {
			printf("%.10lf\n", 0.0);
			continue;
		}
		sort(a, a + n);
		k = n - k;
		double s1 = 0, s2 = 0;
		for (int i = 0; i < k; i++)
			s2 += a[i];
		for (int i = 0; i < k; i++)
			s1 += a[i] * a[i];
		double ans = s1 - s2 * s2 / k * 2 + s2  * s2 / k;
		for (int i = k; i < n; i++) {
			s1 = s1 - a[i - k] * a[i - k] + a[i] * a[i];
			s2 = s2 - a[i - k] + a[i];
			ans = min(ans, s1 - s2 * s2 / k * 2 + s2 * s2 / k);
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}

E:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 55;
int t, n, m;
int g[N][N], dp[N * 2][N], a;

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%d%d", &n, &m);
		for (int i = 1; i <= m; i++)
			for (int j = 1; j <= m; j++)
				scanf("%d", &g[i][j]);
		memset(dp, -INF, sizeof(dp));
		scanf("%d", &a);
		if (a == -1) for (int i = 1; i <= m; i++) dp[1][i] = 0;
		else dp[1][a] = 0;
		int ans = 0;
		for (int i = 2; i <= n; i++) {
			scanf("%d", &a);
			int s, e;
			if (a == -1) s = 1, e = m;
			else s = a, e = a;
			for (int j = s; j <= e; j++) {
				for (int k = 1; k <= m; k++)
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + g[k][j]);
				if (i == n) ans = max(dp[i][j], ans);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

H:

打表程序:

#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 105;

int ans[1005];
int h[N], hn = 0;

int NAND(int a, int b) {
	return (~(a&b))&((1<<8) - 1);
}

vector<int> ss;
int vis[257];

void dfs(int step) {
	ans[h[hn - 1]] = min(ans[h[hn - 1]], step);
	if (step == 9) return;
	int v[257];
	memset(v, 0, sizeof(v));
	for (int i = 0; i < hn; i++) {
		for (int j = i; j < hn ;j++) {
			int tmp = NAND(h[i], h[j]);
			if (v[tmp]) continue;
			v[tmp] = 1;
			if (vis[tmp]) continue;
			h[hn++] = tmp;
			vis[tmp] = 1;
			dfs(step + 1);
			vis[tmp] = 0;
			hn--;
		}
	}
}

int main() {
	memset(ans, INF, sizeof(ans));
	vis[240] = vis[204] = vis[170] = vis[255] = vis[0] = 1;
	h[hn++] = 240; h[hn++] = 204; h[hn++] = 170; h[hn++] = 255; h[hn++] = 0;
	ans[240] = ans[204] = ans[170] = ans[255] = ans[0] = 1;
	dfs(1);
	for (int i = 0; i < 256; i++)
		printf("sb[%d] = %d;\n", i, ans[i]);
	return 0;
}

表:

#include <cstdio>
#include <cstring>

const int INF = 0x3f3f3f3f;
int t;
char str[10];
int sb[300];

int main() {
	sb[0] = 1;
	sb[1] = 8;
	sb[2] = 7;
	sb[3] = 5;
	sb[4] = 7;
	sb[5] = 5;
	sb[6] = 8;
	sb[7] = 5;
	sb[8] = 6;
	sb[9] = 9;
	sb[10] = 4;
	sb[11] = 6;
	sb[12] = 4;
	sb[13] = 6;
	sb[14] = 5;
	sb[15] = 2;
	sb[16] = 7;
	sb[17] = 5;
	sb[18] = 8;
	sb[19] = 5;
	sb[20] = 8;
	sb[21] = 5;
	sb[22] = 11;//就这个是11- -,也就是说如果能优化到跑10步,其实答案就显而易见了
	sb[23] = 8;
	sb[24] = 8;
	sb[25] = 7;
	sb[26] = 8;
	sb[27] = 6;
	sb[28] = 8;
	sb[29] = 6;
	sb[30] = 8;
	sb[31] = 5;
	sb[32] = 6;
	sb[33] = 9;
	sb[34] = 4;
	sb[35] = 6;
	sb[36] = 8;
	sb[37] = 7;
	sb[38] = 8;
	sb[39] = 6;
	sb[40] = 7;
	sb[41] = 1061109567;
	sb[42] = 4;
	sb[43] = 7;
	sb[44] = 7;
	sb[45] = 7;
	sb[46] = 5;
	sb[47] = 4;
	sb[48] = 4;
	sb[49] = 6;
	sb[50] = 5;
	sb[51] = 2;
	sb[52] = 8;
	sb[53] = 6;
	sb[54] = 8;
	sb[55] = 5;
	sb[56] = 7;
	sb[57] = 7;
	sb[58] = 5;
	sb[59] = 4;
	sb[60] = 5;
	sb[61] = 7;
	sb[62] = 8;
	sb[63] = 2;
	sb[64] = 6;
	sb[65] = 9;
	sb[66] = 8;
	sb[67] = 7;
	sb[68] = 4;
	sb[69] = 6;
	sb[70] = 8;
	sb[71] = 6;
	sb[72] = 7;
	sb[73] = 1061109567;
	sb[74] = 7;
	sb[75] = 7;
	sb[76] = 4;
	sb[77] = 7;
	sb[78] = 5;
	sb[79] = 4;
	sb[80] = 4;
	sb[81] = 6;
	sb[82] = 8;
	sb[83] = 6;
	sb[84] = 5;
	sb[85] = 2;
	sb[86] = 8;
	sb[87] = 5;
	sb[88] = 7;
	sb[89] = 7;
	sb[90] = 5;
	sb[91] = 7;
	sb[92] = 5;
	sb[93] = 4;
	sb[94] = 8;
	sb[95] = 2;
	sb[96] = 7;
	sb[97] = 1061109567;
	sb[98] = 7;
	sb[99] = 7;
	sb[100] = 7;
	sb[101] = 7;
	sb[102] = 5;
	sb[103] = 7;
	sb[104] = 9;
	sb[105] = 1061109567;
	sb[106] = 7;
	sb[107] = 9;
	sb[108] = 7;
	sb[109] = 9;
	sb[110] = 6;
	sb[111] = 7;
	sb[112] = 4;
	sb[113] = 7;
	sb[114] = 5;
	sb[115] = 4;
	sb[116] = 5;
	sb[117] = 4;
	sb[118] = 8;
	sb[119] = 2;
	sb[120] = 7;
	sb[121] = 9;
	sb[122] = 6;
	sb[123] = 7;
	sb[124] = 6;
	sb[125] = 7;
	sb[126] = 8;
	sb[127] = 4;
	sb[128] = 5;
	sb[129] = 9;
	sb[130] = 8;
	sb[131] = 7;
	sb[132] = 8;
	sb[133] = 7;
	sb[134] = 9;
	sb[135] = 6;
	sb[136] = 3;
	sb[137] = 9;
	sb[138] = 5;
	sb[139] = 6;
	sb[140] = 5;
	sb[141] = 6;
	sb[142] = 6;
	sb[143] = 3;
	sb[144] = 8;
	sb[145] = 7;
	sb[146] = 9;
	sb[147] = 6;
	sb[148] = 9;
	sb[149] = 6;
	sb[150] = 9;
	sb[151] = 9;
	sb[152] = 8;
	sb[153] = 6;
	sb[154] = 8;
	sb[155] = 6;
	sb[156] = 8;
	sb[157] = 6;
	sb[158] = 9;
	sb[159] = 6;
	sb[160] = 3;
	sb[161] = 9;
	sb[162] = 5;
	sb[163] = 6;
	sb[164] = 8;
	sb[165] = 6;
	sb[166] = 8;
	sb[167] = 6;
	sb[168] = 4;
	sb[169] = 9;
	sb[170] = 1;
	sb[171] = 6;
	sb[172] = 5;
	sb[173] = 7;
	sb[174] = 5;
	sb[175] = 3;
	sb[176] = 5;
	sb[177] = 6;
	sb[178] = 6;
	sb[179] = 3;
	sb[180] = 8;
	sb[181] = 6;
	sb[182] = 9;
	sb[183] = 6;
	sb[184] = 5;
	sb[185] = 7;
	sb[186] = 5;
	sb[187] = 3;
	sb[188] = 7;
	sb[189] = 7;
	sb[190] = 8;
	sb[191] = 5;
	sb[192] = 3;
	sb[193] = 9;
	sb[194] = 8;
	sb[195] = 6;
	sb[196] = 5;
	sb[197] = 6;
	sb[198] = 8;
	sb[199] = 6;
	sb[200] = 4;
	sb[201] = 9;
	sb[202] = 5;
	sb[203] = 7;
	sb[204] = 1;
	sb[205] = 6;
	sb[206] = 5;
	sb[207] = 3;
	sb[208] = 5;
	sb[209] = 6;
	sb[210] = 8;
	sb[211] = 6;
	sb[212] = 6;
	sb[213] = 3;
	sb[214] = 9;
	sb[215] = 6;
	sb[216] = 5;
	sb[217] = 7;
	sb[218] = 7;
	sb[219] = 7;
	sb[220] = 5;
	sb[221] = 3;
	sb[222] = 8;
	sb[223] = 5;
	sb[224] = 4;
	sb[225] = 9;
	sb[226] = 5;
	sb[227] = 7;
	sb[228] = 5;
	sb[229] = 7;
	sb[230] = 7;
	sb[231] = 7;
	sb[232] = 7;
	sb[233] = 1061109567;
	sb[234] = 4;
	sb[235] = 7;
	sb[236] = 4;
	sb[237] = 7;
	sb[238] = 4;
	sb[239] = 6;
	sb[240] = 1;
	sb[241] = 6;
	sb[242] = 5;
	sb[243] = 3;
	sb[244] = 5;
	sb[245] = 3;
	sb[246] = 8;
	sb[247] = 5;
	sb[248] = 4;
	sb[249] = 7;
	sb[250] = 4;
	sb[251] = 6;
	sb[252] = 4;
	sb[253] = 6;
	sb[254] = 7;
	sb[255] = 1;
	scanf("%d", &t);
	while (t--) {
		scanf("%s", str);
		int ans = 0;
		for (int i = 7; i >= 0; i--)
			ans = ans * 2 + str[i] - '0';
		int out = sb[ans];
		if (out == INF) out = 10;
		printf("%d\n", out);
	}
	return 0;
}

I:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int t, n;
const int N = 1005;
struct Point {
	double x, y;
	int t;
	void read() {
		scanf("%d%lf%lf", &t, &x, &y);
	}
} p[N];

bool cmp(Point a, Point b) {
	return a.t < b.t;
}

double dis(Point a, Point b) {
	double dx = a.x - b.x;
	double dy = a.y - b.y;
	return sqrt(dx * dx + dy * dy);
}

int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		for (int i = 0; i < n; i++) {
			p[i].read();
		}
		sort(p, p + n, cmp);
		double ans = 0;
		for (int i = 1; i < n; i++) {
			ans = max(ans, dis(p[i], p[i - 1]) / (p[i].t - p[i - 1].t));
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}

H:事后补

时间: 2024-10-15 16:34:29

2014ACM/ICPC亚洲区鞍山赛区现场赛——题目重现的相关文章

2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!

鞍山的签到题,求两点之间的距离除以时间的最大值.直接暴力过的. A - Osu! Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5078 Appoint description:  System Crawler  (2014-10-22) Description Osu! is a very popular music game. B

2013ACM/ICPC亚洲区南京站现场赛——题目重现

GPA http://acm.hdu.edu.cn/showproblem.php?pid=4802 签到题,输入两个表,注意细心点就行了. 1 #include<cstdio> 2 #include<cstring> 3 const int M=16; 4 char s[M],cp[M][M]={"A","A-","B+","B","B-","C+","

2014ACM/ICPC亚洲区西安站现场赛 F color(二项式反演)

题意:小球排成一排,从m种颜色中选取k种颜色给n个球上色,要求相邻的球的颜色不同,求可行的方案数,答案模1e9+7.T组数据,1<= n, m <= 1e9, 1 <= k <= 1e6, k <= n, m 分析: a(k)表示用不超过k种颜色染n个位置,两两相邻颜色不相同的总数,很简单a(k)=k(n-1)^(k-1) b(k)表示恰好用k种颜色 很显然a(k)=ΣC(k,i)b(i),我们知道a,想知道b,这里就用到二项式反演 那么b(k)=ΣC(k,i)*i*(-1)

2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5984 Pocky 题意 给出一根棒子(可以吃的)的长度x和切割过程中不能小于的长度d,每次随机的选取一个位置切开,吃掉左边的一半,对右边的棒子同样操作,直至剩余的长度不大于d时停止.现在给出x和d,问切割次数的数学期望是多少. 解题思路 当看到第二个样例2 1时,结果是1.693147,联想到ln

HDU 5074 Hatsune Miku(2014鞍山赛区现场赛E题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5074 解题报告:给出一个长度为n的序列,例如a1,a2,a3,a4......an,然后这个序列的美丽值就是socre[a1][a2] + socre[a2][a3] + ..... socre[an-1][an],但是这个序列里面并不是所有的数都是确定的,输入包含一些大于0的数和一些-1,-1表示这个数可以任意,但是要在m的范围内,给出socre[i][j],求这个序列最大的美丽值. 一个二维dp

HDU 5071 Chat(2014鞍山赛区现场赛B题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 解题报告:一个管理聊天窗口的程序,一共有八种操作,然后要注意的就是Top操作只是把编号为u的窗口标记为一种特殊的状态,在这种特殊的状态下优先级是最高的,聊天都是跟这个聊,而这个窗口并没有在实际上被提到最前面.还有就是每句后面都有句号.我本来可以1A的,但就是因为没看这个,所以一直WA也找不到原因. 暴力模拟就可以了,因为点最多只有5000个,不会超时,维护一个队列就可以了,但我为了方便判断是不

hdu-4810 Wall Painting 2013ACM/ICPC亚洲区南京站现场赛

题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4810 解题思路: 记录下每个数的各个位上1个数的和,根据题意,异或要产生数值,必须是取基数个1,通过组合数学的方法,比如要在6个1里面取三个1,则取得方法有C(6,3),那么如何可以快速取得C(6,3)呢?通过杨辉三角形打表即可 #include <iostream> #include <cstdio> #include <cstring> using namespace s

Song Jiang&#39;s rank list(杭电oj5131)(2014ACM/ICPC亚洲区广州站)

Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 168    Accepted Submission(s): 91 Problem Description <Shui Hu Zhuan>,also <Water Margin>was written by Shi Nai'a

HDU 4119 Isabella&#39;s Message (2011年成都赛区现场赛I题)

1.题目描述:点击打开链接 2.解题思路:本题是一道模拟题,要求模拟一个解密的过程,练习这么久第一次做模拟题1Y了,内心还是很激动的~.只需要根据题意,记录* 所在的位置即可,然后每次都是先解密,后顺时针旋转90度.把每次解密的信息放到一个vector里,接下来就是连接它们,得到解密后的字符串,在map中查找这些单词是否存在即可.如果都存在,就把这条解密信息放到ans中,最后对ans排序,输出ans[0]就是答案. 3.代码: //#pragma comment(linker, "/STACK: