2017四川省省赛E
来源:互联网 发布:卡佩拉详细数据 编辑:程序博客网 时间:2024/04/28 18:15
这道题我赛时没看懂,没理解上,赛后补题的时候看了dalao的代码懂得。这里n^2logn会T,那么我们想办法去掉logn,这里需要我们理解lis的本质,即去掉序列中的一个数,那么以i结尾的序列的LIS的长度要吗不变,要么-1,
#include <bits/stdc++.h>#define maxs 202020#define mme(I,j) memset(I,j,sizeof(I))using namespace std;const int inf = ( ~(1<<31) );inline long long read(){ long long x=0,f=1; char ch = getchar(); for(;ch<'0'||ch>'9';ch =getchar() ) if(ch == '-') f= -1; for(;ch>='0'&&ch<='9';ch = getchar()) x = (x<<3)+(x<<1)+ch-'0'; return x*f;}int a[maxs];int f[maxs];int t[maxs];int main(){ int n; while(~scanf("%d",&n)) { for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++){ f[i]=1; for(int j=1;j<i;j++) if(a[i]>a[j]) f[i]=max(f[i],f[j]+1); } int ans,tmp; for(int del=1;del<=n;del++){ for(int i=1;i<=n;i++) t[i]=inf; ans = 0 ; for(int j=1;j<=n;j++) { if(j==del)continue; if( t[f[j]-1]< a[j] ) tmp = f[j]; else tmp = f[j]-1; t[tmp]=min(t[tmp],a[j]); ans ^= (tmp*tmp); } printf("%d%c",ans,(del==n)?'\n':' '); } } return 0;}
阅读全文
0 0
- 2017四川省省赛E
- 2017四川省省赛E
- 2017四川省省赛G
- SCU 4440 Rectangle (2015四川省省赛E题)
- 2017 四川省赛 E.Longest Increasing Subsequence【思维+贪心】
- 2017四川省赛E题( Longest Increasing Subsequence)
- 2016 四川省赛 E. Coins 找规律 .
- 四川省赛-E king's trouble II
- ACM2017四川省赛 E Longest Increasing Subsequence
- 2017四川省省赛A题
- 2017四川省赛总结
- 2016四川省省赛总结
- 四川省赛
- UESTC486(2011四川省省赛)
- 2017四川省赛G题2017
- 2017四川省赛A题Simple Arithmetic
- 2017四川省赛F题Simple Algebra
- 2017 四川省赛 D. Dynamic Graph
- Camera安卓源码-高通mm_camera架构剖析
- Linux环境下sudo切换用户后执行其他命令
- DICOM基本环境配置
- Fragment系列之嵌套导致错乱的onActivityResult数据传递
- 屏幕旋转切换EditText不保存数据问题
- 2017四川省省赛E
- UVa10340--All in All--子序列--字符串模拟
- Java精选笔记_DBUtils工具
- 继承
- hibernate中取出一个对像,set后数据库中发生变化
- --Satoshi--大数据的学习日志(2017.07.17)
- 移植ucGUI相关问题
- 搬砖中的小事之代码(六)--列表显示的字段与数据库中字段类型不匹配,需要在查询后进行简单转换
- SVM 准备工作(SVM vs LR)