题解区第三篇题解(@Last_Flame)的代码会被如下生成器生成的数据 hack 掉:
#include<bits/stdc++.h>
#define MAXN 200010
using namespace std;
int n = 200000, b;
int main()
{
freopen("mst.in", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cout << n << "\n";
b = n / 2;
for (int i = 1; i <= b; ++i) cout << i << " ";
for (int i = b + 1; i <= n; ++i) cout << 1000000000 << " ";
cout << "\n";
for (int i = 1; i <= b; ++i) cout << i << " " << b + 1 << " " << 1000000002 - 2 * i << "\n";
for (int i = b + 2; i <= n; ++i) cout << i - 1 << " " << i << " 1\n";
return 0;
}
具体原理:图由一个链和链一段的一个菊花组成。由于作者对点权排了序,忽略了边权,导致菊花上的的点会不断更新链上的点,使复杂度退化为 O(n2)。
hack 自测链接:https://www.luogu.com.cn/problem/U421850
目前该题解的代码会在该数据上超时,而其他题解的代码能够正常通过。
本人已经联系了题解作者@Last_Flame ,他表示会修改代码。建议将此 Hack 加入数据。