作者太巨辣!

%%%乔猫

好。

ZJ一下:

哭笑不得。

T1直接审错题(没发现题目里那个憨P的更新限制),然后直接跑了$\mathsf{SPFA}$,然后我又发现了。以为我死了,结果手玩一下发现……那句话没有用……

试图卡一下$\mathsf{SPFA}$但是发现卡不掉,我想这么水一题卡毛线$\mathsf{SPFA}$,于是就扔掉了。

T2打了贪心错解组合版,但是自己大力$\text{hack}$完后就以为死了,后来还有$30pts$,作者太友好了(感动

T3发现直接在角度上维护即可,于是码完,然后发现给的端点真不友好,不是左上右下,而是左下右上,后来还被卡精了$\text{kuku}$

这是TJ:

T1:

名正言顺的AC了。

作者没有构造卡$\mathsf{SPFA}$的数据……

很不明白网格图上咋卡……

#include <iostream>
#include <cstring>
#include <cstdio>
#define N 555 using namespace std; const int mx[]={0, 0,1,-1},
my[]={1,-1,0, 0};
typedef pair<int,int> pii;
template<typename T>
class Myqueue{
T A[N*N*100];
int f,b;
public:
Myqueue(){f=b=0;}
void clear(){f=b=0;}
void push(const T k){A[b++]=k;}
void pop(){f++;}
T front(){return A[f];}
bool empty(){return f==b;}
};
Myqueue<pii>q;
int lines,cols;
int tps[N][N],lps[N][N];
int fix,fiy;
bool inq[N][N];
void pour(){
for(int i=1;i<=3;i++){
for(int j=1;j<=cols;j++){
cout<<"----";
}
if(i!=3)cout<<"+";
}
puts("");
for(int i=1;i<=lines;i++){
for(int j=1;j<=cols;j++)
printf("%4d",lps[i][j]);
cout<<"|";
for(int j=1;j<=cols;j++)
printf("%4d",tps[i][j]);
cout<<"|";
for(int j=1;j<=cols;j++)
printf("%4d",inq[i][j]);
puts("");
}
/* puts("------Inqueue----------");
for(int i=1;i<=lines;i++){
for(int j=1;j<=cols;j++){
printf("%4d",inq[i][j]);
}puts("");
}*/
}
inline bool in_b(int x,int y){
return x>=1&&x<=lines&&y>=1&&y<=cols;
}
inline bool in_b(pii ps){
return in_b(ps.first,ps.second);
}
void bfs(int x,int y){//?
q.push(make_pair(x,y));
inq[x][y]=1;
while(!q.empty()){
int fx=q.front().first,
fy=q.front().second;
// cout<<fx<<" "<<fy<<endl;
q.pop();
if(q.empty())q.clear();
inq[fx][fy]=0;//?Double UPD??
for(int i=0;i<4;i++){
int tx=fx+mx[i],
ty=fy+my[i];
if(in_b(tx,ty) && lps[tx][ty]<lps[fx][fy]-tps[tx][ty]){
lps[tx][ty]=lps[fx][fy]-tps[tx][ty];
if(!inq[tx][ty]){
q.push(make_pair(tx,ty));
inq[tx][ty]=1;
}
}
}
// pour();
}
}
int main(){
// freopen("neworld.in" ,"r",stdin);\
freopen("neworld.out","w",stdout);
int a,b,c;
scanf("%d%d",&lines,&cols);
for(int i=1;i<=lines;i++)
for(int j=1;j<=cols;j++)
scanf("%d",&tps[i][j]);
scanf("%d%d%d%d%d",&a,&b,&c,&fix,&fiy);
lps[a][b]=c;
bfs(a,b);
printf("%d\n",lps[fix][fiy]);
// cerr<<clock()<<endl;
}

叫$\mathsf{BFS}$但是是$\mathsf{SPFA}$

T2:

状压即可,细节还行。

#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio> //#include "debug.h" #define N 111
#define M 10
#define S (1<<9)+10 using namespace std; int dp[N][S],mp[N];
int lines,cols,maxs; inline int lowbit(int x){
return x&(-x);
}
inline int count(int x){
int n_1=0;
while(x){
x-=lowbit(x);
n_1++;
}
return n_1;
}
bool is_ok(int i1,int pos1){
for(int i=1;i<=cols;i++){
int j=1<<(i-1);
if(j&pos1){
if(!(j&mp[i1]))return false;
}
}
for(int i=1;i<=cols;i++){
int j=1<<(i-1);
if((j&mp[i1])&&(!((j>>1)&mp[i1]))){
if(!(j&pos1))return false;
}
}
return true;
}
int get_merge(int i1,int pos1,int i2,int pos2){
int dat=0;
for(int i=1;i<=cols;){
int j=1<<(i-1);
// cout<<i<<" Outout"<<endl;
if((pos1&j) && (pos2&j)){
int k=i+1,l=1<<(k-1);
while(1){
//cerr<<k<<endl;
if(k>cols){
dat++;
break;
}
if(((!(l&mp[i1])) || (l&pos1)) && \
((!(l&mp[i2])) || (l&pos2))){
// puts("All WA");
dat++;
break;
}
else if( (l&mp[i1])&&(l&mp[i2])&&(!(l&pos1))&&(!(l&pos2)) ){
//puts("One WA");
k++,l=1<<(k-1);
}
else
break;
//puts("Contined");
}
i=k;
continue;
}
i++;
}
// cout<<"Res:"<<dat<<endl;
return dat;
}
int main(){
ios_base::sync_with_stdio(false);
int a;
cin>>lines>>cols;
maxs=(1<<cols)-1;
for(int i=1;i<=lines;i++){
for(int j=1;j<=cols;j++){
cin>>a;
mp[i]|=a<<(j-1);
}
}
// for(int i=1;i<=lines;i++)\\
cerr<<bin(mp[i],cols)<<endl;
memset(dp,0x3f,sizeof dp);
for(int s=0;s<1<<cols;s++){
if(is_ok(1,s)){
dp[1][s]=count(s);
// cerr<<dp[1][s]<<" "<<bin(s,cols)<<endl;
}
}
for(int i=2;i<=lines;i++){
for(int s=0;s<1<<cols;s++){
if(!is_ok(i,s))continue;
for(int t=0;t<1<<cols;t++){
if(!is_ok(i-1,t))continue;
//cerr<<"Mp["<<i<<"]="<<bin(mp[i],cols)\
<<" S:"<<bin(s,cols)<<" "\
<<"Mp["<<i-1<<"]="<<bin(mp[i-1],cols)\
<<" T:"<<bin(t,cols)<<endl;
int val=count(s)-get_merge(i,s,i-1,t);
// cout<<"val:"<<get_merge(i,s,i-1,t)<<endl;
dp[i][s]=min(dp[i][s],
dp[i-1][t]+val);
// cout<<"dp["<<i<<"]["<<bin(s,cols)<<"]="<<dp[i][s]<<endl;
}
}
}
int ans=INT_MAX;
for(int s=0;s<1<<cols;s++)
if(is_ok(lines,s))
ans=min(ans,dp[lines][s]);
cout<<ans<<endl;
}

T3:

不会!

19-10-27-S的更多相关文章

  1. 背水一战 Windows 10 (27) - 控件(文本类): TextBlock

    [源码下载] 背水一战 Windows 10 (27) - 控件(文本类): TextBlock 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) TextBlock 示例 ...

  2. 第15次Scrum会议(10/27)【欢迎来怼】

    一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/27 17:20~17:45,总计25min. 地点 ...

  3. JZOJ 4269. 【NOIP2015模拟10.27】挑竹签

    4269. [NOIP2015模拟10.27]挑竹签 (File IO): input:mikado.in output:mikado.out Time Limits: 1000 ms  Memory ...

  4. Ubuntu 19.10 发布 | 云原生生态周报 Vol. 24

    作者 | 木苏.进超.冬岛.元毅.心水.衷源 业界要闻 1.云原生编程语言 Pulumi 1.0 pulumi ,一款中立的开源云开发平台,Pulumi 支持多语言.混合云环境.完全可扩展.初期支持 ...

  5. [Linux] 在 Ubuntu 19.10 上开启 SSH 服务并允许远程登录

    在 Ubuntu 19.10 上安装 SSH,并开启服务 0.检查并确认系统当前是否已安装SSH: sudo ps -e | grep ssh 如果只有 ssh-agent 说明 ssh-server ...

  6. [Linux] 树莓派 4B 安装 Ubuntu 19.10 (Eoan Ermine) IOT 版

    硬件:Raspberry Pi 4B系统:Ubuntu 19.10 (Eoan Ermine) for IOT官网:https://ubuntu.com/download/iot/raspberry- ...

  7. Ubuntu 19.10 安装 jupyter

    安装pip3 ubuntu 19.10 已经没有python了,取代的是python3. 执行sudo apt install python3-pip安装pip3 安装jupyter 执行sudo p ...

  8. Ubuntu 19.10将使用GCC 9作为默认编译器

    作为我们这一周期一直期待的变化,Ubuntu 19.10升级到GCC 9作为GCC 8的默认系统编译器. Ubuntu 19.10(和Ubuntu 20.04 LTS)将使用GCC 9 stable作 ...

  9. Unix 网络编程卷一源码编译踩坑记录 ubtutu 19.10

    在阅读unpv1时运行源代码的环境配置,这里简单记录一下 源代码里的README 写得挺详细的,但是在Linux 系统的下还没没办法直接编译通过的, 这里我使用的是ubuntu 19.10(在腾讯云1 ...

  10. 程序员的 Ubuntu 19.10 配置与优化指南

    原文地址:程序员的 Ubuntu 19.10 配置与优化指南 0x00 环境 CPU: Intel Core i9-9900k GPU: GeForce RTX 2070 SUPER RAM: DDR ...

随机推荐

  1. mysql安装总结

    #mysql安装# 安装工具:yum -y install gcc-c++ ncurses cmake make ncurses-devel # 拷贝配置文件到指定目录:rm -rf /etc/my. ...

  2. C 自己实现strcpy,strcmp,strlen,strcat等函数

    // mystrlen() 测试字符长度方法 int mystrlen(char *str) { int cnt = 0; char *p= str; while(*p++ != '\0') { cn ...

  3. vue使用CDN全局安装百度地图

    参考: https://www.zhangshengrong.com/p/O3aA7x5X4E/ 一.在public/index.html中引入cdn <script src="htt ...

  4. Java 仓储模式

    使用的Spring boot +Jpa 项目层级: common里包含了model,以及一些viewModel等等 下面就是设计的仓储模式 先看下SysUser: @MappedSuperclass ...

  5. mysql-connetor-c 自动创建数据库、数据库表的命令

    1.首先连接MySQL默认的数据库mysql // 参数说明: // strIP: MySQL数据库的IP地址 // nPort: MySQL数据库的端口号 // strDBName: 要连接的数据库 ...

  6. robotframework冷门关键字

    1.Reload Page 模拟页面重载 2.Register Keyword To Run On Failure 参数: Keyword 描述: 当Selenium2Library类库关键字执行失败 ...

  7. 40. 组合总和 II

    题目描述: 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合. candidates 中的每个数字在每个组合中只 ...

  8. java 堆排,优先级队列,归并排序

    堆排 堆排是基于二叉树而得来的 例如:对一个数组 可以转为二叉树:       二叉树特性父节点为 i ,  左叶子节点为2i+1:右叶子节点为2i+2; 步骤分解: 1. 先从第一个非叶子节点(即下 ...

  9. day15 python-03 列表,元组,字典

    Python之路,Day3 = Python基础3 注: extend: 拼接 enumerate:打印序号,返回两个值 模块的简单使用 sys模块 #!/usr/bin/env python #这句 ...

  10. 牛客多校第五场 A digits 2 签到

    题意: 给定一个n,输出一个数,要求这个数所有位之和整除n,并且这个数也整除n,并且位数不许多于1e4 题解: 把这个数n输出n遍. #include<iostream> using na ...