又被辉神吊打了。今天不仅被辉神李巨吊打,还给基本上给全班垫底了。

看到T3就知道是十进制快速幂,全机房考试的当时应该就我会,结果我tm没找到递推。

Orz lyc BM直接水过,Orz wys六个for循环出递推,Orz辉神手推n^2递推。

不敢说话,我去背BM板子了。

这样下去大概NOIp继续被辉神李巨吊打,可以退役回去学常规了。

1 餐馆 (restaurant)

完全背包裸题。

 //Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define Formylove return 0
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=;
typedef long long LL;
typedef double db;
using namespace std;
int T,n,m,S,t[N],w[N];
LL f[N],ans; template<typename T>void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} #define ANS
int main() {
#ifdef ANS
freopen("restaurant.in","r",stdin);
freopen("restaurant.out","w",stdout);
#endif
read(T);
while(T--) {
memset(f,,sizeof(f));
read(n); read(m); read(S);
For(i,,n) {
read(t[i]); read(w[i]);
}
For(i,,m) { read(t[n+i]); read(w[n+i]); }
For(i,,m) For(j,,n) {
int x; read(x);
if(x>) t[n+i]+=x*t[j];
}
For(i,,n+m) For(j,t[i],S)
f[j]=max(f[j],f[j-t[i]]+w[i]);
ans=;
For(j,,S) ans=max(ans,f[j]);
printf("%lld\n",ans);
}
Formylove;
}

2 烯烃 (olefin)

树形dp裸题,最最基础的换根操作。

 //Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define Formylove return 0
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=1e5+;
typedef long long LL;
typedef double db;
using namespace std;
int id,T,n,m,tag[N],ans[N]; template<typename T>void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} int ecnt,fir[N],nxt[N<<],to[N<<],fa[N];
void add(int u,int v) {
nxt[++ecnt]=fir[u]; fir[u]=ecnt; to[ecnt]=v;
} int f[N];
void dfs(int x) {
f[x]=;
for(int i=fir[x];i;i=nxt[i]) {
dfs(to[i]);
f[x]=max(f[x],f[to[i]]+);
}
} void get_max(int &a,int b) { if(b>a) a=b; } void dfs2(int x,int ff) {
int se=,fi=x==?:ff+;
for(int i=fir[x];i;i=nxt[i]) {
se=max(se,f[to[i]]+);
if(se>fi) swap(fi,se);
}
for(int i=fir[x];i;i=nxt[i]) if(tag[to[i]]) {
if(fi==f[to[i]]+) get_max(ans[tag[to[i]]],se+f[to[i]]+);
else get_max(ans[tag[to[i]]],fi+f[to[i]]+);
}
for(int i=fir[x];i;i=nxt[i]) {
if(f[to[i]]+==fi) dfs2(to[i],se);
else dfs2(to[i],fi);
}
} void init() {
ecnt=;
memset(ans,,sizeof(ans));
memset(fir,,sizeof(fir));
memset(tag,,sizeof(tag));
} #define ANS
int main() {
#ifdef ANS
freopen("olefin.in","r",stdin);
freopen("olefin.out","w",stdout);
#endif
read(id);
read(T);
while(T--) {
init();
read(n); read(m);
For(i,,n) {
read(fa[i]);
add(fa[i],i);
}
For(i,,m) {
int x;
read(x);
tag[x]=i;
}
dfs();
dfs2(,);
For(i,,m-) printf("%d ",ans[i]);
if(m) printf("%d\n",ans[m]);
}
Formylove;
}

3 三米诺 (tromino)

十进制快速幂,我不会找递推,只能用背BM板子然后水过去。

 //Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define Formylove return 0
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=,p=;
typedef long long LL;
typedef double db;
using namespace std;
char s[N];
LL n,f[]={,,,,,,,,,,}; template<typename T>void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} struct jz {
LL a[][];
friend jz operator *(const jz&A,const jz&B) {
jz rs;
For(i,,) For(j,,) {
rs.a[i][j]=;
For(k,,)
(rs.a[i][j]+=A.a[i][k]*B.a[k][j]%p)%=p;
}
return rs;
}
}bs,rs; void ksm() {
int len=strlen(s);
int ok=;
Rep(i,len-,) {
int c;
c=s[i]-'';
if(!ok) {
c--;
if(c<) c+=;
else ok=;
}
For(i,,c) rs=rs*bs;
jz pr=bs;
For(i,,) bs=bs*pr;
}
} #define ANS
int main() {
#ifdef ANS
freopen("tromino.in","r",stdin);
freopen("tromino.out","w",stdout);
#endif
scanf("%s",s);
For(i,,) For(j,,) rs.a[i][j]=bs.a[i][j]=;
For(i,,) {
rs.a[i][i]=;
if(i<) bs.a[i+][i]=;
}
bs.a[][]=;
bs.a[][]=;
bs.a[][]=;
bs.a[][]=;
bs.a[][]=p-;
ksm();
LL ans=;
For(i,,)
(ans+=rs.a[i][]*f[i+]%p)%=p;
printf("%lld\n",ans);
Formylove;
}

NOIp2018集训test-9-7(pm) (联考一day1)的更多相关文章

  1. NOIp2018集训test-9-22(am/pm) (联考三day1/day2)

    szzq学长出的题,先orz一下. day1 倾斜的线 做过差不多的题,写在我自己的博客里,我却忘得一干二净,反而李巨记得清清楚楚我写了的. 题目就是要最小化这个东西 $|\frac{y_i-y_j} ...

  2. NOIp2018集训test-9-15(联考二day1)

    T1.矩阵游戏 水题.每一行最后乘的数为x[i],每一列为y[i],暴力算第一行的列的贡献,每一行的列的贡献是公差为所有列的贡献之和的等差数列,然后每一行再乘上行的贡献求和即为答案. //Achen ...

  3. 六省联考2017 Day1

    目录 2018.3.18 Test T1 BZOJ.4868.[六省联考2017]期末考试 T2 T3 BZOJ.4870.[六省联考2017]组合数问题(DP 矩阵快速幂) 总结 考试代码 T1 T ...

  4. NOIp2018集训test-9-8(pm) (联考一day2)

    把T1题读错了,想了一个多小时发现不可做.然后打了t2,常数不优秀.然后去打t3,lct,结果打挂爆0了. 然后今天就爆炸了. 如果这是noip我今年就可以直接回去学常规了.学常规多好,多开心. 今天 ...

  5. NOIp2018集训test-10-6/test-10-7 (联考五day1/day2)

    昨天考完月考,明天初赛,dcoi2017级今天终于开始停课准备noip了,大概没有比本弱校停课更晚的学校了吧.本来就够菜了,怕是要凉透哦. DAY1 T1石头剪刀布 据说爆搜随便做,但是我觉得我的O( ...

  6. NOIp2018集训test-10-21 (联考六day1)

    今天被高一狂踩,两个手抖,t1一个1写成2,t3一个+=写成=,所谓失之毫厘谬以千里,直接丢了50分. 完全背包 看到背包体积如此之大物品体积如此之小容易很想到贪心,肯定要先加很多很多的性价比最高的最 ...

  7. NOIp2018集训test-10-4/test-10-5 (联考四day1/day2)

    这个day1稍微有点毒瘤吧?? DAY1 排列 以前总是把day1t1想太复杂了翻车,差不多往正解的方向想了一下感觉不可能这么复杂这可是noipday1t1啊一定有非常简单的方法然后翻车了?? 题目转 ...

  8. NOIp2018集训test-10-24(am&pm)

    李巨连续AK三场了,我跟南瓜打赌李巨连续AK七场,南瓜赌李巨连续AK五场. DAY1 T1 qu 按题意拿stack,queue和priority_que模拟即可.特判没有元素却要取出的情况. T2 ...

  9. ZR10.1青岛集训三地联考

    ZR10.1青岛集训三地联考 谢谢dijk和smy A 题目大意: 已知斐波那契数列\(f\) 设 \[ F_i = \sum_{i = 0}^nf_if_{n - i} \] 求 \[ \sum_{ ...

随机推荐

  1. 从文本文件hello.txt到可执行文件hello

    第一阶段 使用编辑器编写的源代码 (.txt) 文件 hello.c.经过 Pre-processor 进行前处理.在前处理阶段,当 pre-processor 读到代码中的#include<s ...

  2. Windows下生成目录结构树

    1.进入需要生成目录结构的文件主目录 2.在当前目录打开命令行 3.输入命令 tree /f > list.txt 4.即在当前目录下生成了list.txt文件

  3. HIVE的Shell操作

    1.Hive支持的一些命令 退出使用quit或exit离开交互式外壳. set key = value使用它来设置特定配置变量的值. 这里要注意的一件事是,如果您对变量名拼写错误,cli将不会显示错误 ...

  4. C/C++ 智能指针线程池

    //这个线程池存在一定的BUG 如果没有多线程编程基础的先生请谨慎使用 //我放弃了这种模板方式的线程池,最好不要使用!!!!!!! ThreadPool.h { #ifndef __THREADPO ...

  5. loadrunner自定义函数

    https://zhangfy068.iteye.com/blog/1614794 Loadruner 有四种实现自定义函数的方式,根据脚本编写方便性进行选择不同的方式. (1)直接引用法: Acti ...

  6. 如何修改magento分类页面的产品的显示个数

    经常的有客户问,怎么修改分类页面的产品的个数 这个是magneto后台操作的设置问题 打开后台,在英文状态下: system-->configuration 进入后,点击catalog Prod ...

  7. BZOJ 3328: PYXFIB 解题报告

    BZOJ 3328: PYXFIB 题意 给定\(n,p,k(1\le n\le 10^{18},1\le k\le 20000,1\le p\le 10^9,p \ is \ prime,k|(p- ...

  8. J2EE学习篇之--Spring技术详解

    今天我们来看一下Spring的相关知识,我们知道Spring也是一个开源的框架,这个框架并不像是Struts一样,这个框架是可以用在Java的所有地方,所以,其实开发Android的时候我们也是可以使 ...

  9. Delphi 虚拟桌面

    Delphi创建虚拟桌面实现后台调用外部程序 核心提示:最近在做的一个软件,其中有一部分功能需要调用其它的软件来完成,而那个软件只有可执行文件,根本没有源代码,幸好,我要做的事不难,只需要在我的程序启 ...

  10. App响应式布局

    1.手机的响应式布局,所有的单位用rem来表示. 如:设计稿的宽度是750,则html标签的font-size=屏幕宽度/7.5.那么在网页中的尺寸 = 设计高上实际的尺寸/100. 把下面的代码作为 ...