欢乐%你赛,大家都AK了。

1. 小澳的方阵

吸取了前几天的教训,我一往复杂的什么二维树状数组上想就立刻打住阻止自己,就可以发现它是超级大水题了。记录每一行每一列最后一次的修改,对每个格子看它所在行和列哪一个修改更靠后即可。

  1. //Achen
  2. #include<algorithm>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<cstdlib>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<queue>
  9. #include<cmath>
  10. #include<set>
  11. #include<map>
  12. #define Formylove return 0
  13. #define For(i,a,b) for(int i=(a);i<=(b);i++)
  14. #define Rep(i,a,b) for(int i=(a);i>=(b);i--)
  15. const int N=;
  16. typedef long long LL;
  17. typedef double db;
  18. using namespace std;
  19. int n,m,q,h[N][],l[N][];
  20.  
  21. template<typename T>void read(T &x) {
  22. char ch=getchar(); x=; T f=;
  23. while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
  24. if(ch=='-') f=-,ch=getchar();
  25. for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
  26. }
  27.  
  28. #define ANS
  29. int main() {
  30. #ifdef ANS
  31. freopen("matrix.in","r",stdin);
  32. freopen("matrix.out","w",stdout);
  33. #endif
  34. read(n); read(m); read(q);
  35. For(i,,q) {
  36. int x,y,z;
  37. read(x); read(y); read(z);
  38. if(x==) h[y][]=z,h[y][]=i;
  39. else l[y][]=z,l[y][]=i;
  40. }
  41. For(i,,n) {
  42. For(j,,m) {
  43. if(h[i][]<l[j][]) printf("%d ",l[j][]);
  44. else printf("%d ",h[i][]);
  45. } puts("");
  46. }
  47. Formylove;
  48. }

2. 小澳的坐标系

可以暴搜或者打个n^2dp(根据竖着走上多少行,每一行走多少步,往左还是往右dp)找规律。我不会找规律,就继续yy怎么更优秀地dp。

f[i][0]表示走i步的方案,f[i][1]表示走i步且最后一步往上走的方案。

若最后一步往左走,下一步可以往左,往上 2种走法

若最后一步往右走,下一步可以往右,往上 2种走法

若最后一步往上走,下一步可以往左,往右,往上 3种走法

所以 f[i][0]=f[i-1][0]*2+f[i-1][1]

显然 f[i][1]=f[i-1][0]

这个递推方程一出来,就可以套矩乘板子了。

  1. //Achen
  2. #include<algorithm>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<cstdlib>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<queue>
  9. #include<cmath>
  10. #include<set>
  11. #include<map>
  12. #define Formylove return 0
  13. #define For(i,a,b) for(int i=(a);i<=(b);i++)
  14. #define Rep(i,a,b) for(int i=(a);i>=(b);i--)
  15. const int N=,p=1e9+;
  16. typedef long long LL;
  17. typedef double db;
  18. using namespace std;
  19. int n;
  20.  
  21. template<typename T>void read(T &x) {
  22. char ch=getchar(); x=; T f=;
  23. while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
  24. if(ch=='-') f=-,ch=getchar();
  25. for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
  26. }
  27.  
  28. struct jz {
  29. LL a[][];
  30. friend jz operator *(const jz&A,const jz&B) {
  31. jz rs;
  32. For(i,,) For(j,,) {
  33. rs.a[i][j]=;
  34. For(k,,)
  35. (rs.a[i][j]+=A.a[i][k]*B.a[k][j]%p)%=p;
  36. }
  37. return rs;
  38. }
  39. }bs,rs;
  40.  
  41. void ksm(int b) {
  42. while(b) {
  43. if(b&) rs=rs*bs;
  44. bs=bs*bs;
  45. b>>=;
  46. }
  47. }
  48.  
  49. #define ANS
  50. int main() {
  51. #ifdef ANS
  52. freopen("coordinate.in","r",stdin);
  53. freopen("coordinate.out","w",stdout);
  54. #endif
  55. read(n);
  56. rs.a[][]=rs.a[][]=;
  57. rs.a[][]=rs.a[][]=;
  58. bs.a[][]=; bs.a[][]=;
  59. bs.a[][]=; bs.a[][]=;
  60. ksm(n-);
  61. LL ans=(3LL*rs.a[][]%p+1LL*rs.a[][])%p;
  62. printf("%lld\n",ans);
  63. Formylove;
  64. }

3.小澳的葫芦

dp[x][y]表示从1到x经过y个点的最短路。

DAG上dp,拓扑排序即可。

  1. //Achen
  2. #include<algorithm>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<cstdlib>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<queue>
  9. #include<cmath>
  10. #include<set>
  11. #include<map>
  12. #define Formylove return 0
  13. #define For(i,a,b) for(int i=(a);i<=(b);i++)
  14. #define Rep(i,a,b) for(int i=(a);i>=(b);i--)
  15. const int N=,M=;
  16. typedef long long LL;
  17. typedef double db;
  18. using namespace std;
  19. int n,m,f[N][N];
  20.  
  21. template<typename T>void read(T &x) {
  22. char ch=getchar(); x=; T f=;
  23. while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
  24. if(ch=='-') f=-,ch=getchar();
  25. for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
  26. }
  27.  
  28. int ecnt,fir[N],nxt[M],to[M],val[M],in[N];
  29. void add(int u,int v,int w) {
  30. nxt[++ecnt]=fir[u]; fir[u]=ecnt; to[ecnt]=v; val[ecnt]=w; in[v]++;
  31. }
  32.  
  33. queue<int>que;
  34. void tpsort() {
  35. memset(f,/,sizeof(f));
  36. int inf=f[][];
  37. f[][]=;
  38. For(i,,n) if(!in[i]) que.push(i);
  39. while(!que.empty()) {
  40. int x=que.front();
  41. que.pop();
  42. for(int i=fir[x];i;i=nxt[i]) {
  43. in[to[i]]--;
  44. if(!in[to[i]]) que.push(to[i]);
  45. For(j,,n) if(f[x][j]!=inf) {
  46. if(f[x][j]+val[i]<f[to[i]][j+])
  47. f[to[i]][j+]=f[x][j]+val[i];
  48. }
  49. }
  50. }
  51. }
  52.  
  53. #define ANS
  54. int main() {
  55. #ifdef ANS
  56. freopen("calabash.in","r",stdin);
  57. freopen("calabash.out","w",stdout);
  58. #endif
  59. read(n); read(m);
  60. For(i,,m) {
  61. int u,v,w;
  62. read(u); read(v); read(w);
  63. add(u,v,w);
  64. }
  65. tpsort();
  66. db ans=1e18;
  67. For(i,,n) ans=min(ans,(db)f[n][i]/(1.0*i));
  68. printf("%lf\n",ans);
  69. Formylove;
  70. }

NOIp2018集训test-9-1(pm)的更多相关文章

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

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

  2. NOIp2018集训test-9-21(am/pm)

    Am DAY1 抄代码 送分题 //Achen #include<bits/stdc++.h> #define For(i,a,b) for(int i=(a);i<=(b);i++ ...

  3. NOIp2018集训test-9-19(am&pm)

    AM 这是一套在长沙考过而且我能记得全部正解的题,然后期望得分300实际得分155. T1 很套路,随便搞(我当年是怎么花大半场时间写T1并且写出现在两倍长的代码的??) //Achen #inclu ...

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

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

  5. NOIp2018集训test-9-17(pm)

    T1记忆(memory) 我大概是只记忆只有七秒的金鱼吧.看了下以前的代码发现真的很简单,但是考场上只打了个暴力,虽然骗了88pt.就是枚举选的是哪个串,然后vis[i]表示选了i这些位能不能猜出它, ...

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

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

  7. NOIp2018集训test-9-7(pm) (联考一day1)

    又被辉神吊打了.今天不仅被辉神李巨吊打,还给基本上给全班垫底了. 看到T3就知道是十进制快速幂,全机房考试的当时应该就我会,结果我tm没找到递推. Orz lyc BM直接水过,Orz wys六个fo ...

  8. NOIp2018集训test-9-6(pm)

    T1T2是洛谷原题.Orz辉神290,被辉神吊起来打. 题 1 包裹快递 二分答案.这题似乎卡精度,不开long double二分500次都过不去. //Achen #include<algor ...

  9. NOIp2018集训test-9-5(pm)

    老张说:这套题太简单啦,你们最多两个小时就可以AK啦! 题 1 数数 我看到T1就懵了,这就是老张两个小时可以AK的题的T1?? 然后我成功地T1写了1h+,后面1h打了t2.t3暴力,就很开心. 等 ...

  10. NOIp2018集训test-9-2(pm)

    其实这套题我爆0了,T1define 写成ddefine编译错误 T2有两个变量爆int 但是我看zwh不在悄悄地改了,我心里还是十分愧疚(没有)的.主要是林巨已经虐我125了要是再虐我200分我大概 ...

随机推荐

  1. Aajx调用千千音乐数据接口

    前端展示截图https://images.cnblogs.com/cnblogs_com/LiuFqiang/1429011/o_D09Q55)EL1VFEIJ(GKI%7D%7DY5.png < ...

  2. Go: Println 与 Printf 的区别

    Go 学习笔记:Println 与 Printf 的区别,以及 Printf 的详细用法 2017-12-19 15:39:05 zgh0711 阅读数 26255更多 分类专栏: Go   版权声明 ...

  3. 富文本 保存转义StringEscapeUtils.unescapeHtml4(

    StringEscapeUtils.unescapeHtml4( [org.apache.commons.lang.StringEscapeUtils.escapeHtml(str)] [String ...

  4. Dart编程实例 - Const 关键字

    Dart编程实例 - Const 关键字 void main() { final v1 = 12; const v2 = 13; v2 = 12; } 本文转自:http://codingdict.c ...

  5. 如何基于 Nacos 和 Sentinel ,实现灰度路由和流量防护一体化

    基于Alibaba Nacos和Sentinel,实现灰度路由和流量防护一体化的解决方案,发布在最新的 Nepxion Discovery 5.4.0 版,具体参考: 源码主页,请访问 源码主页指南主 ...

  6. 简单的使用Qt的QCustomplot画图

    一.新建一个widget工程 二.将Qcustomplot文件复制到项目下 三.右键qt项目增加已存在的文件 四.在.pro中添加 QT += widgets printsupport 五.在.h中添 ...

  7. 大牛公司的github

    Google Google https://github.com/google Google Samples https://github.com/googlesamples Google Codel ...

  8. AcWing 143. 最大异或对 01字典树打卡

    在给定的N个整数A1,A2……ANA1,A2……AN中选出两个进行xor(异或)运算,得到的结果最大是多少? 输入格式 第一行输入一个整数N. 第二行输入N个整数A1A1-ANAN. 输出格式 输出一 ...

  9. 30天轻松学习javaweb_修改tomcat的servlet模板

    在MyEclipse目录下搜索com.genuitec.eclipse.wizards 得到搜索结果 com.genuitec.eclipse.wizards_9.0.0.me201108091322 ...

  10. HTML5自定义属性的设置与获取

    <div id="box" aaa="bbb" data-info="hello"></div> <body& ...