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

看到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. node js实战:带数据库,加密的注册登录表单

    demo 注册效果: 登陆效果:        数据库截图: 数据库操作 db.js //这个模块里面封装了所有对数据库的常用操作 var MongoClient = require('mongodb ...

  2. java的集合工具类Collections

    集合框架的工具类. Collections:集合框架的工具类.里面定义的都是静态方法. Collections和Collection有什么区别? Collection是集合框架中的一个顶层接口,它里面 ...

  3. putty字体和颜色修改

    来源:https://www.igvita.com/2008/04/14/custom-putty-color-themes/ 网站上有putty的注册表,可以修改putty显示的配色方案. 非常棒!

  4. 51nod-1515 明辨是非——并查集

    给n组操作,每组操作形式为x y p. 当p为1时,如果第x变量和第y个变量可以相等,则输出YES,并限制他们相等:否则输出NO,并忽略此次操作. 当p为0时,如果第x变量和第y个变量可以不相等,则输 ...

  5. Useful code snippets with C++ boost

    Useful code snippets with C++ boost Is Punctuation It’s very straight forward to use boost.regex as ...

  6. ajax请求是的动画实现

    ajax请求是的动画实现 ajax是基于XMLHttpRequest对象封装,ajax的具体属性就有: 参数名 类型 描述 url String (默认: 当前页地址) 发送请求的地址. type S ...

  7. gthub获得star指南

    https://mp.weixin.qq.com/s/EmyK1Fm5MDWQcrUxP8Tcgg

  8. HDU 6685 Rikka with Coin (枚举 思维)

    2019 杭电多校 9 1006 题目链接:HDU 6685 比赛链接:2019 Multi-University Training Contest 9 Problem Description Rik ...

  9. 1067 Sort with Swap(0, i) (25 分)

    Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order ...

  10. shell默认参数脚本

    如果不加参数则默认执行restart函数,加stop,则执行stop函数 #!/bin/bash # version function stop(){ # stop the command } fun ...