万年rk2

我写挂大家都挂但是有人比我挂的少

我好不容易卡一波常数然后有人ak

。。。

T1.不想写,等会放链接

T2

给一个方阵,每个地方有一个权值,把它划成两块,不能往回拐弯,求两块极差较大的那个极差最小值是多少

显然,二分极差

然后贪心的画一条线,保证它不拐弯就可以了

T3

你下了一个$10^{18}$攻的克苏恩,对面有一个无限血的英雄和一个奴隶主,求这个克苏恩期望打多少下脸

首先,只有7个格子,场面只跟奴隶主的血量有关(也没有火舌管站位干吗)

然后我们可以搜一发状态,发现只有165个

我们用$f_{i,s}$表示打了$i$下当前场面为$s$的期望打脸次数

$s$怎么处理呢?哈希一下咯

然后发现我们可以矩阵乘法,对于打脸的情况,另单开一行就可以了

当然要记得自己转移自己...

但这样还不够,复杂度$O(T \times 165^3 \times logn)$显然过不了

考虑到最后我们只需要矩阵的一行中的几个元素而不是整个矩阵,又想到向量乘矩阵是$O(n ^ 2)$的

我们可以预处理出转移矩阵的$2^t$次方,查询的时候相当于倍增,乘一次是$O(n ^ 2)$的

于是就是$O(165^3 \times logn + T \times 165^2 logn)$的

然而还是卡不过去,我们考虑优化取模,首先当然是要

inline void add(LL &x,LL delt){x += delt;if(x >= mod)x -= mod;}

其实这样加了O2我们已经可以过了

然而本机1.5s的我还是慌得一批

于是我们可以找一个很大的数,然后每次先膜这个大的,最后再膜998244353,$O(n^3)$次取膜变成了$O(n^2)$次的

现在问题出在怎么找这个数上,一开始想的是找一个很大的质数,后来发现完全没必要质数,找一个20位左右的数就可以了

这样就可以卡进1s了

#include<bits/stdc++.h>
#define LL long long
using namespace std;
inline int read()
{
int x = ,f = ;char ch = getchar();
for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
for(;isdigit(ch);ch = getchar())x = * x + ch - '';
return x * f;
}
const int maxn = ;
int h,w;
int a[maxn][maxn],mn = ,mx;
int l,r,ans;
int chk(int mid)
{
int upb = mx - mid,lwb = mn + mid,j,lim = w + ;
for(int i=;i<=h;i++)
{
for(j=;j<lim;j++)if(a[i][j] < upb)break;
lim = min(lim,j);
for(j=lim;j<=w;j++)if(a[i][j] > lwb)return ;
}
return ;
}
void divide()
{
l = ;
while(l < r)
{
int mid = (l + r) >> ;
if(chk(mid))r = mid;
else l = mid + ;
}
}
int main()
{
h = read(),w = read();
for(int i=;i<=h;i++)
for(int j=;j<=w;j++)
{
a[i][j] = read();
mn = min(mn,a[i][j]);
mx = max(mx,a[i][j]);
}
r = mx - mn;divide();
for(int i=;i<=h/;i++)swap(a[i],a[h - i + ]);divide();
for(int i=;i<=h;i++)reverse(a[i] + ,a[i] + w + );divide();
for(int i=;i<=h/;i++)swap(a[i],a[h - i + ]);divide();
cout<<r;
}

T2

#include<bits/stdc++.h>
#define LL unsigned long long
using namespace std;
inline LL read()
{
LL x = ,f = ;char ch = getchar();
for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
for(;isdigit(ch);ch = getchar())x = * x + ch - '';
return x * f;
}
char buf[],top; inline void write(LL x,char opt = )
{
while(x)
{
buf[++top] = (char){x % + ''};
x = x / ;
}
for(;top;top--)putchar(buf[top]);
if(opt)putchar(opt);
}
const LL mod = ;
const LL BIGNUM = (0x7fffffffffffffffll / mod - mod) * mod;
inline void BIGADD(LL &x,LL delt)
{
x += delt;
if(x >= BIGNUM)x -= BIGNUM;
}
int m,k;
LL n;
LL ans[],tmp[];
int pos[][][],dfn;
struct Matrix
{
LL a[][];
int w,h;
void init(int ww,int hh)
{
w = ww;h = hh;
memset(a,,sizeof(a));
}
Matrix operator * (const Matrix &b)const
{
Matrix res;
res.init(h,b.w);
for(int i=;i<=h;i++)
for(int j=;j<=b.w;j++)
{
for(int k=;k<=w;k++)
BIGADD(res.a[i][j] , a[i][k] * b.a[k][j]);
res.a[i][j] %= mod;
}
return res;
}
}Vec[];
inline void Matrix_Mul_Vector(Matrix Trans,LL* w)
{
memset(tmp,,sizeof(tmp));
for(int i=;i<=Trans.h;i++)
{
for(int j=;j<=Trans.w;j++)
{
BIGADD(tmp[i] , Trans.a[i][j] * w[j]);
}
tmp[i] %= mod;
}
memcpy(w,tmp,sizeof(tmp));
} inline LL ksm(LL x,LL k)
{
LL ans = ;
while(k)
{
if(k & )ans = (ans * x) % mod;
x = (x * x) % mod;
k = k >> ;
}
return ans;
}
LL inve[];
int main()
{
//freopen("gen.in","r",stdin);
//freopen("gen1.out","w",stdout);
int T = read();m = read(),k = read();
for(int i=;i<=k+;i++)inve[i] = ksm(i,mod - );
//write(T);write(m);write(k);
int lb,jb,ib;
if(m > )lb = k;else lb = ;
for(int l=;l<=lb;l++)
{
if(m > )jb = k - l;
else jb = ;
for(int j=;j<=jb;j++)
{
if(m)ib = k - j - l;
else ib = ;
for(int i=;i<=ib;i++)
{
pos[i][j][l] = ++dfn;
}
}
}
for(int i=;i<=;i++)Vec[i].init(dfn + ,dfn + );
if(m)ib = k;else ib = ;
for(int i=;i<=ib;i++)
{
if(m > )jb = k - i;else jb = ;
for(int j=;j<=jb;j++)
{
if(m > )lb = k - j - i;else lb = ;
for(int l=;l<=lb;l++)
{
int cnt = i + j + l,nowpos = pos[i][j][l],tolim = (cnt < k);
LL inv = inve[cnt + ];
if(m == )
{
Vec[].a[nowpos][pos[i - ][][]] = (i * inv) % mod;
}
if(m == )
{
if(i != )Vec[].a[nowpos][pos[i - ][j][]] = (i * inv) % mod;
if(j != )Vec[].a[nowpos][pos[i + ][j + tolim - ][]] = (j * inv) % mod;
}
if(m == )
{
if(i != )Vec[].a[nowpos][pos[i - ][j][l]] = (i * inv) % mod;
if(j != )Vec[].a[nowpos][pos[i + ][j - ][l + tolim]] = (j * inv) % mod;
if(l != )Vec[].a[nowpos][pos[i][j + ][l + tolim - ]] = (l * inv) % mod;
}
Vec[].a[nowpos][nowpos] = Vec[].a[nowpos][dfn + ] = inv;
}
}
}
Vec[].a[dfn + ][dfn + ] = ;
for(int i=;i<=;i++)Vec[i] = Vec[i - ] * Vec[i - ];
while(T--)
{
n = read();
memset(ans,,sizeof(ans));
ans[dfn + ] = ;
for(int l=;l<=;l++)
if(n & (1LL << l))Matrix_Mul_Vector(Vec[l],ans);
if(m == )write(ans[pos[][][]],'\n');
if(m == )write(ans[pos[][][]],'\n');
if(m == )write(ans[pos[][][]],'\n');
}
}

T3

noip模拟赛 #2的更多相关文章

  1. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  2. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  3. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  4. 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程

    数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...

  5. 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...

  6. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...

  7. 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...

  8. CH Round #58 - OrzCC杯noip模拟赛day2

    A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...

  9. CH Round #52 - Thinking Bear #1 (NOIP模拟赛)

    A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...

  10. CH Round #49 - Streaming #4 (NOIP模拟赛Day2)

    A.二叉树的的根 题目:http://www.contesthunter.org/contest/CH%20Round%20%2349%20-%20Streaming%20%234%20(NOIP 模 ...

随机推荐

  1. swiper-demo1

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. web 表单方式上传文件方法(不用flash插件)

    原理:使用表单的input type="file"标签,通过ajax提交表单请求,后台获取请求中的文件信息,进行文件保存操作 由于我测试用的做了一个上传文件和上传图片方法,所以我有 ...

  3. Gson把对象转成json格式的字符串

    近期在做一个java web service项目,须要用到jason,本人对java不是特别精通,于是開始搜索一些java平台的json类库. 发现了google的gson.由于之前对于protoco ...

  4. NativeBase准备工作

    环境 node>= 4.0 npm>= 3.0 rnpm (only if React Native version < 0.29) ReactNativeCLI  安装及运行 ht ...

  5. Node.js下载及安装

    Node.js是一个基于Chrome JavaScript运行时建立的平台, 用于方便地搭建响应速度快.易于扩展的网络应用. Node.js 使用事件驱动, 非阻塞I/O 模型而得以轻量和高效,非常适 ...

  6. session 的工作原理以及使用细节和url编码

    /**********************************************模拟页面************************************************* ...

  7. 搭建私有Nuget仓库

    使用Nexus搭建私有Nuget仓库 https://www.cnblogs.com/Erik_Xu/p/9211471.html 前言 Nuget是ASP .NET Gallery的一员,是免费.开 ...

  8. 多媒体开发之---如何确定slice_header slice_type 的位置

    引用网友的问答:我找到0x000001 NAL的开头了,请问如何确定slice head的位置,继而得出slice_type呢?Nal unit后紧跟的就是slice head吗?标准里的循环让人看得 ...

  9. nodejs实如今线群聊

    这不是一个项目而是一个适合刚開始学习的人学习的样例.主要实现了下面基本功能: 1:群聊.每个人都能够收到其它人的消息,以及能够发消息给其它人,每个人用ip地址标识. 2:显示当前在线用户. 3:每个用 ...

  10. 视频服务之ffmpeg部署

    FFmpeg介绍 FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序. 采用LGPL或GPL许可证.它提供了录制.转换以及流化音视频的完整解决方案. 它包含了非常先进 ...