社区讨论
如何嫖分
P2607[ZJOI2008] 骑士参与者 6已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @locwbkt6
- 此快照首次捕获于
- 2023/10/30 20:48 2 年前
- 此快照最后确认于
- 2023/11/05 07:16 2 年前
RT,摸你推活只能40,如何嫖到60
CPP#include<bits/stdc++.h>
#define rg register int
#define cold 0.996
#define T_e 1e-25
using namespace std;
double T_s=50000.0;
int N,temp,nowans,ans,hate,loc,stc[400040],cnt,fin;
bool pd[5001][5001],rem[5001],nmsl[5001][5001];
struct node{
int power;
int num;
}knight[400040];
bool jud(int a)
{
for(rg i=1;i<=cnt;i++)
{
if(pd[a][stc[i]]==1&&pd[stc[i]][a]==1)
{
return false;
}
}
return true;
}
void SA()
{
T_s=50000.0;
int x=0,y=0;cnt=0;nowans=0;
bool flag=false;
while(T_s>T_e)
{
x=rand()%N+1;
y=rand()%N+1;
// cout<<"x:"<<x<<" "<<"y:"<<y<<endl;
for(rg i=1;i<=N;i++)
{
if(jud(i)) flag=true;
}
if(!flag) return ;
if(knight[x].power>=knight[y].power&&jud(x))
{
stc[++cnt]=x;
for(rg i=1;i<=cnt;i++)
{
pd[stc[i]][x]=1;pd[x][stc[i]]=1;
}
// cout<<"nowans:"<<nowans<<" "<<"x:"<<x<<endl;
nowans+=knight[x].power;
// cout<<nowans<<endl;
}
if(ans-nowans<0) ans=nowans;
else
{
if(exp((nowans-ans)/T_s)*RAND_MAX<rand()&&jud(x))
{
stc[++cnt]=x;
for(rg i=1;i<=cnt;i++)
{
pd[stc[i]][x]=1;pd[x][stc[i]]=1;
}
// cout<<"nmsl"<<endl;
nowans+=knight[x].power;
ans=nowans;
}
}
T_s*=cold;
}
// cout<<endl<<endl;
return ;
}
signed main()
{
// freopen("knight.in","r",stdin);
// freopen("knight.out","w",stdout);
srand(time(NULL));
scanf("%d",&N);
for(rg i=1;i<=N;i++)
{
scanf("%d",&knight[i].power);
fin=max(fin,knight[i].power);
scanf("%d",&hate);
pd[hate][i]=1;
pd[i][hate]=1;
}
memcpy(nmsl,pd,sizeof nmsl);
while((double)clock()/CLOCKS_PER_SEC<0.989)
{
memset(stc,0,sizeof stc);
memcpy(pd,nmsl,sizeof pd);
SA();
fin=max(fin,ans);
// cout<<endl<<endl<<endl;
}
printf("%d\n",fin);
return 0;
}
/*
3
10 2
20 3
30 1
*/
回复
共 6 条回复,欢迎继续交流。
正在加载回复...