社区讨论
20分最最弱智极简爆搜为何WA?
P11233[CSP-S 2024] 染色参与者 3已保存回复 8
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 8 条
- 当前快照
- 1 份
- 快照标识符
- @mhk7g8kh
- 此快照首次捕获于
- 2025/11/04 14:45 4 个月前
- 此快照最后确认于
- 2025/11/04 14:45 4 个月前
过了样例1 样例2 爆T答案输不出来
CPP#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define f(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
const int N=2*1e5+5;
int n,T;
int a[N],c[N];
int ans;
using namespace std;
void Init()
{
ans=-1;
}
void dfs(int x)
{
if(x==n)
{
int res=0;
f(i,1,n)
for(int j=i-1;j>=1;--j)
if(c[i]==c[j]&&a[i]==a[j]) res+=a[j];
// f(i,1,n) cout<<c[i]<<' ';
// cout<<endl<<res<<endl;
ans=max(ans,res);
return;
}
c[x]=0;
dfs(x+1);
c[x]=1;
dfs(x+1);
}
signed main()
{
// freopen("color.in","r",stdin);
// freopen("color.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>T;
while(T--)
{
cin>>n;
Init();
f(i,1,n)
{
cin>>a[i];
//same[a[i]].push_back(i);
}
dfs(1);
cout<<ans<<endl;
}
return 0;
}
回复
共 8 条回复,欢迎继续交流。
正在加载回复...