传送门

## T1

区间修改+单点查询。差分树状数组。

#include<iostream>
#include<cstdio>
#include<cstring> using namespace std;
const int MAXN = ; inline int rd(){
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {f=ch=='-'?:;ch=getchar();}
while(isdigit(ch)) {x=(x<<)+(x<<)+ch-'';ch=getchar();}
return f?x:-x;
} void out(int x){
if(!x) return;
out(x/);
putchar(''+x%);
} int f[MAXN],n,m,ans; void update(int x,int k){
for(;x<=n;x+=x&-x) f[x]+=k;
} int query(int x){
int ret=;
for(;x;x-=x&-x) ret+=f[x];
return ret;
} int main(){
// freopen("Agent3.in","r",stdin);
// freopen("T1.out","w",stdout);
n=rd(),m=rd();
int x,y,op;
while(m--){
op=rd();
if(op==) {
x=rd();y=rd();
update(x,);update(y+,-);
}
else{
x=rd();ans=query(x);if(!ans) putchar('');
else out(query(x));putchar('\n');
}
}
return ;
}

## T2

比赛的时候算错复杂度,以为是个模拟。拿了$60pts$的暴力分。正解要用双向链表,不太想写,留坑。

## T3

状压$dp$,考试的时候题意中有句话不理解,写了三份代码,结果发现都过不了大样例 ($wtf??$),最后快结束时瞎交了一份,结果拿了90。。最后发现中间有个地方没开$long long$ ,亏死。设$dp[S][i]$表示现在选的集合为$S$,最后一个选的为$i$的最大收益,然后再枚举一个集合外的元素$j$,进行转移。时间复杂度$O(2^n*n)$

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define int long long using namespace std;
const int MAXN = ;
typedef long long LL; inline int rd(){
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {f=ch=='-'?:;ch=getchar();}
while(isdigit(ch)) {x=(x<<)+(x<<)+ch-'';ch=getchar();}
return f?x:-x;
} int n,m,K,t[MAXN];
int val[MAXN],ex[MAXN][MAXN];
LL dp[<<MAXN][MAXN],ans; inline void MAX(){
int S=;
for(register int i=;i<=m;i++) S|=(<<(t[i]-));
for(register int i=;i<=m;i++) ans=max(ans,dp[S][t[i]]);
} void dfs(int x,int now){
if(now==m) {MAX();return;}
if(x==n+) return;
t[now+]=x;dfs(x+,now+);
t[now+]=;dfs(x+,now);
} signed main(){
// memset(dp,-0x3f,sizeof(dp));
n=rd(),m=rd();K=rd();int x,y;
for(register int i=;i<=n;i++) val[i]=rd();
for(register int i=;i<=K;i++){
x=rd(),y=rd();
ex[x][y]+=rd();
}dp[][]=;
for(register int i=;i<=n;i++) dp[<<(i-)][i]=val[i];
for(register int S=;S<<<n;S++)
for(register int i=;i<=n;i++)if((S&(<<(i-))))
for(register int j=;j<=n;j++)if(!(S&(<<(j-))))
dp[S|(<<(j-))][j]=max(dp[S|(<<(j-))][j],dp[S][i]+val[j]+ex[i][j]);
// cout<<ans<<endl;
dfs(,);
cout<<ans<<endl;
return ;
}

最新文章

  1. WebAPI的Get和Post访问
  2. Android 开发必备知识:我和 Gradle 有个约会
  3. JSP+JavaBean+Servlet+Oracle新增功能中对Date类型的字段的处理
  4. JMS学习(三)JMS 消息结构之属性及消息体详解
  5. POJ 3580:SuperMemo(Splay)
  6. ACM题目————A除以B
  7. H TML5 之 (3)转动的圆球
  8. PHPCMS get当中使用limit
  9. EasyCHM(CHM电子书制作工具) v3.84.545 绿色版
  10. 微坑---微信小程序ios上时间字符串转换为时间戳时,在开发工具上和安卓手机上运行成功
  11. 设置webstorm缩写代码
  12. 在网站开发中经常用到的javaScript技术
  13. MySQL InnoDB 存储引擎探秘
  14. Linux Django项目部署
  15. postman抓包工具与kap项目部署(新猿旺学习总结)
  16. Appium系列文章(1)获取appPackage和appActivity
  17. 【转】联想笔记本进入u盘启动项操作方法详解
  18. Amazon RDS多区域高可用测试
  19. Iterator 与ListIterator的区别
  20. 工欲善其事,必先利其器 软件工具开发关键词 protractor自动化测试工具 RegexBuddy正则 CodeSmith,LightSwitch:代码生成 CheatEngine:玩游戏修改内存值必备神器 ApkIDE:Android反编译工具 Reflector:反编译dll动态链接库

热门文章

  1. uoj21 【UR #1】缩进优化
  2. Mysql集群和主从
  3. 最短路(模板Dtra
  4. Java oop第08章_JDBC01(入门)
  5. static/extern&amp;const个人理解
  6. YARN体系结构
  7. Java创建List、Map等集合对象的同时进行赋值操作
  8. Python学习笔记(五)——异常处理
  9. WinDBG常用断点命令
  10. UVA-11987-Almost Union-Find-并查集的基本操作合并、删除、移位