当前位置:网站首页>Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
2022-07-01 02:24:00 【不吃土司边】
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
const int maxn = 1e5+2;
const int INF = 1<<30;
const int mod = 1e9+7;
int dp[maxn],n,a[maxn];
int cnt[maxn],cnt2[maxn];
int res[maxn];
void solve(){
;
scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d",&a[i]),cnt[a[i]]++;
for(int i=1;i<=n;i++){
int now=0,now2=0;
memset(cnt2,0,sizeof cnt2);
for(int j=i;j>=1;j--){
if(cnt2[a[j]]==0) now++,now2^=a[j];
cnt2[a[j]]++;
if(cnt2[a[j]]==cnt[a[j]]) --now;
if(!now){
res[i]=max(res[i],res[j-1]+now2);
}
}
res[i]=max(res[i],res[i-1]);
}
cout<<res[n]<<endl;
return;
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- 【JS】【掘金】获取关注了里不在关注者里的人
- 手机上怎么开户?还有,在线开户安全么?
- [punch in questions] integrated daily 5 questions sharing (phase I)
- Pulsar geo replication/ disaster recovery / regional replication
- Analysis and solution of anr problems
- Leetcode(524)——通过删除字母匹配到字典里最长单词
- 522. 最长的特殊序列 II
- Live shopping mall source code, realize left-right linkage of commodity classification pages
- SWT/ANR问题--AMS/WMS
- What is project management?
猜你喜欢

SWT/ANR问题--Binder Stuck

Go import self built package

Leetcode interview question 17.10 Main elements

Pychar open remote directory remote host

How to use Jieba participle in unity
![[2022] Jiangxi postgraduate mathematical modeling scheme and code](/img/f4/86b0dc2bd49c3a54c1e0538b31d458.png)
[2022] Jiangxi postgraduate mathematical modeling scheme and code

A preliminary understanding of operator overloading

VirtualBox installation enhancements

Leetcode 面试题 17.10. 主要元素

Calculate special bonus
随机推荐
UE4渲染管线学习笔记
MySQL insert \ pre update + judgment condition
C # generates PPK files in putty format (supports passphrase)
Open source basic software companies, looking for you to create the future together (api7.ai)
如何在智汀中實現智能鎖與燈、智能窗簾電機場景聯動?
Video tutorial | Chang'an chain launched a series of video tutorial collections (Introduction)
集群方法同步执行框架 Suona
How to learn and read code
The latest wechat iPad protocol code obtains official account authorization, etc
Some uses of Halcon array
端口号和进程号的区别?
Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"
The image variables in the Halcon variable window are not displayed, and it is useless to restart the software and the computer
QML control type: tooltip
Desai wisdom number - other charts (parallel coordinate chart): employment of fresh majors in 2021
Int and bit group turn to each other
Leetcode (524) -- match the longest word in the dictionary by deleting letters
机器学习10-信念贝叶斯分类器
What is project management?
Analysis and solution of anr problems