对于本题唯一一篇题解的代码里有这句话:
const int co=6;
题解里说最优解一定有 6 种颜色的方案。
但是根据如下数据生成器输出的代码:
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>X;
int B[]={0,6,5,6,5,6,6,6,0};
int main()
{
freopen("w.in","w",stderr);
int z=1;
for(int i=1;B[i];++i)
{
for(int o=1;o<=z;++o)
{
for(int j=1;j<B[i];++j)
X.emplace_back(o,o+j*z);
}
z*=(B[i]);
}
cerr<<X.size()+1<<" "<<0<<endl;
for(auto k:X)cerr<<k.first<<" "<<k.second<<'\n';
cerr<<0.001<<endl;
}
题解在 const int co=7; 时输出 756.305;
在 const int co=6; 时输出 756.293。
事实上,B 数组如果下标 1∼x 都是 x 可以卡掉 const int co=x 的做法,并且正确答案应该在 const int co=x+1。