警示后人,如果你48pts RE
查看原帖
警示后人,如果你48pts RE
752017
buowen123楼主2024/10/21 17:21

你可能判错了首尾相等 a1=a2na_1 = a_{2n} 的情况。

错误:
	for (int i = 2; i < 2 * n; i++) {
		if (a[i] == a[1]) pos1 = i;
		if (a[i] == a[2 * n]) pos2 = i;
	}
正确:
	for (int i = 2; i <= 2 * n; i++) 
		if (a[i] == a[1]) pos1 = i;
	for (int i = 1; i < 2 * n; i++) 
		if (a[i] == a[2 * n]) pos2 = i;
2024/10/21 17:21
加载中...