传送门

分析

我们可以建一个k层图,把dp转移的三维对应到每个点上,每个第k层点连向0层点

我们让第0层点为实点其余为虚点,只要碰到虚点就dfs到他连得所有实点再将实点入队即可

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
priority_queue<pair<int,int> >q;
bool vis[][][];
int d[],v[],a[],b[],n,m,K,res;
inline void go(int x,int y,int z){
if(vis[x][y][z])return;
vis[x][y][z]=;
if(x==m){
if(y==K&&z<n&&res+b[z]<d[z]){
d[z]=res+b[z];
q.push(make_pair(-d[z],z));
}
}else {
go(x+,y,z);
if(y<K)go(x+,y+,z^(<<x));
}
}
int main(){
int i,j,k;
scanf("%d%d",&n,&K);
while((<<m)<n)m++;
memset(d,0x3,sizeof(d));
for(i=;i<n;i++){
scanf("%d",&v[i]);
if(v[i]>=)d[i]=v[i],q.push(make_pair(-d[i],i));
}
for(i=;i<n;i++)scanf("%d",&a[i]);
for(i=;i<n;i++)scanf("%d",&b[i]);
while(!q.empty()){
int x=q.top().second,y=-q.top().first;
cout<<y<<endl;
q.pop();
if(x<n){
if(y>d[x])continue;
q.push(make_pair(-y-a[x],x+n));
}else {
res=y;
go(,,x-n);
}
}
int Ans=;
for(i=;i<n;i++)Ans^=d[i];
cout<<Ans;
return ;
}

EZOJ #226的更多相关文章

  1. Android Weekly Notes Issue #226

    Android Weekly Issue #226 October 9th, 2016 Android Weekly Issue #226 本期内容包括: 用Firebase做A/B Test; 用R ...

  2. 226. Invert Binary Tree(C++)

    226. Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 ...

  3. LeetCode Javascript实现 258. Add Digits 104. Maximum Depth of Binary Tree 226. Invert Binary Tree

    258. Add Digits Digit root 数根问题 /** * @param {number} num * @return {number} */ var addDigits = func ...

  4. C#版 - 226. Invert Binary Tree(剑指offer 面试题19) - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - 2 ...

  5. centos 7 IP不能访问nginx Failed connect to 185.239.226.111:80; No route to host解决办法

    服务器环境 centos 7.4 问题描述 1.可以ping通IP ,用IP访问nginx 不能访问,在服务器上curl localhost  curl 185.239.226.111可以获得 [ro ...

  6. LeetCode:翻转二叉树【226】

    LeetCode:翻转二叉树[226] 题目描述 翻转一棵二叉树. 示例: 输入: 4 / \ 2 7 / \ / \ 1 3 6 9 输出: 4 / \ 7 2 / \ / \ 9 6 3 1 题目 ...

  7. 市场上 MLCC 226 电容现象

    市场上 MLCC 226 电容现象 三星 X7R 1206 没有 16V 也有人在卖. Y5V 当 X7R 卖. X5R 当 X7R 卖. 薄电容当厚的电容卖.

  8. &lt;LeetCode OJ&gt; 226. Invert Binary Tree

    226. Invert Binary Tree Total Accepted: 57653 Total Submissions: 136144 Difficulty: Easy Invert a bi ...

  9. x509: certificate is valid for 10.96.0.1, 172.18.255.243, not 120.79.23.226

    服务器:阿里云服务器 master:120.79.23.226 node:39.108.131.246 系统:Centos 7.4 node节点加入集群中是报错: x509: certificate ...

随机推荐

  1. JEECG获取当前登录人的值

    TSUser user = ResourceUtil.getSessionUserName(); mv.addObject("fbillerid", user.getUserNam ...

  2. STM32学习笔记之__attribute__ ((at())绝对定位分析

    STM32也会遇到这样的绝对定位的问题如下: uint8_t   UART_RX_BUF[1024]   __attribute__ ((at(0X20001000)));   //就是将串口接收的数 ...

  3. MySQL的Query Cache原理分析

    QueryCache(下面简称QC)是根据SQL语句来cache的.一个SQL查询如果以select开头,那么MySQL服务器将尝试对其使用QC.每个Cache都是以SQL文本作为key来存的. 原理 ...

  4. Data_Structure01-绪论作业

    一.作业题目 仿照三元组或复数的抽象数据类型写出有理数抽象数据类型的描述 (有理数是其分子.分母均为整数且分母不为零的分数). 有理数基本运算: 构造有理数T,元素e1,e2分别被赋以分子.分母值 销 ...

  5. node制作代理服务器

    下面代码实现的功能是这样的: 首先创建一个HTTP服务器,当服务器接收到客户端的请求后,向"www.taobao.com"网站请求数据,当从该网站接受到的响应数据后,将响应数据发送 ...

  6. 检测SqlServer服务器性能

    通过性能监视器监视 Avg. Disk Queue Length   小于2 Avg. Disk sec/Read , Avg. Disk sec/Write  小于10ms 可以用数据收集器定时收集 ...

  7. 遇到版本兼容问题时 Newtonsoft.Json

    <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <depen ...

  8. idea展现目录清晰方式

  9. ubuntu安装Percona Server

    Percona Server是mysql数据库的一个衍生版本,在性能,稳定性和可管理性上都有很大的提升,目前淘宝的mysql数据库就是基于Percona Server,请原谅我这么喜欢研究淘宝的技术. ...

  10. java byte to hex

    String str; byte[] bs = null; bs =str.getBytes(); bs =str.getBytes("utf-8") java  byte to ...