去年的对拍noip上用不了...

不知道是不是机子的问题...换了一种对拍。

以洛谷11月月赛T2为例。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;

int n;

int h[320],vis[320];

LL ans;

void dfs(int now,int a,LL scor)
{
    if(a==n)
    {
        ans=max(ans,scor);
        return ;
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]) continue;
        vis[i]=true;
        dfs(i,a+1,scor+(h[now]-h[i])*(h[now]-h[i]));
        vis[i]=false;
    }
}

int main()
{
    freopen("rand.txt","r",stdin);
    freopen("baoli.txt","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&h[i]);
    dfs(0,0,0);
    cout<<ans<<endl;
    return 0;
}
暴力程序

相关文章:

猜你喜欢
  • 2021-08-23
  • 2022-12-23
  • 2022-03-04
  • 2021-11-14
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案