昨晚深夜修仙上紫记,虽然不错还是很有遗憾的。

A. Maxim and Biology

看完就会做的题,然而手速跟不上

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=510;char ss[110]; int a[110];
int getdis(int x,int y)
{if(x>y)swap(x,y);return min(y-x,x+26-y);
}
int main()
{int n,m;scanf("%d%s",&n,ss+1);for(int i=1;i<=n;i++)a[i]=ss[i]-'A'+1;int mn=(1<<30);for(int i=1;i<=n-3;i++){mn=min(mn,getdis(a[i],1)+getdis(a[i+1],3)+getdis(a[i+2],20)+getdis(a[i+3],7));}printf("%d\n",mn);return 0;
}

A. Maxim and Biology

B. Dima and a Bad XOR

其实先开的是B,但是O(nm*1024)相当不靠谱不是很敢写。。。后来写得还是磕磕绊绊总之相当不爽。就是那种要抢时间这个题又烦的一批的感觉

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=510;int a[maxn][maxn];
bool f[maxn][1024];int d[maxn][1024],fr[maxn][1024]; int as[maxn];
int main()
{int n,m,mx=0;scanf("%d%d",&n,&m);f[0][0]=true;for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&a[i][j]),mx=max(mx,a[i][j]);while(mx!=(mx&-mx))mx-=(mx&-mx);mx<<=1;if(mx==0)mx=2;for(int i=0;i<n;i++)for(int zt=0;zt<mx;zt++)if(f[i][zt]){for(int j=1;j<=m;j++)f[i+1][zt^a[i+1][j]]=true,d[i+1][zt^a[i+1][j]]=j,fr[i+1][zt^a[i+1][j]]=zt;}for(int zt=1;zt<mx;zt++)if(f[n][zt]){puts("TAK");for(int i=n;i>=1;i--){as[i]=d[i][zt],zt=fr[i][zt];}for(int i=1;i<=n;i++)printf("%d ",as[i]);puts("");return 0;}puts("NIE");return 0;
}

B. Dima and a Bad XOR

C. Problem for Nazar

和B一起让我自闭了半个多小时,看错一发题意。其实就是按题意模拟,然后写到45min才过真是!@#¥%……&,也是疯狂调试没什么底的,还好样例比较强。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
inline LL ad(LL x,LL y){return (x>=mod-y)?(x-mod+y):x+y;}
inline LL re(LL x,LL y){return (x<y)?(x-y+mod):x-y;}LL solve(LL n)
{if(n==0)return 0;int op=1; LL i,step=0,ost=1,est=2,ret=0;for(i=1;i<=n;i<<=1){if(step+i>=n)break;if(op==1){LL ed=ost+2*(i-1);ret=ad(ret,(ost+ed)%mod*(i%mod)%mod*(mod/2+1)%mod);ost=ed+2;}else{LL ed=est+2*(i-1);ret=ad(ret,(est+ed)%mod*(i%mod)%mod*(mod/2+1)%mod);est=ed+2;}op^=1;step+=i;}if(op==1){LL ed=ost+2*(n-step-1);if(ed%2==0)ed--;ret=ad(ret,(ost+ed)%mod*((n-step)%mod)%mod*(mod/2+1)%mod);}else{LL ed=est+2*(n-step-1);if(ed%2==1)ed--;ret=ad(ret,(est+ed)%mod*((n-step)%mod)%mod*(mod/2+1)%mod);}return ret;
}int main()
{LL l,r;scanf("%lld%lld",&l,&r);printf("%lld\n",re(solve(r),solve(l-1)));return 0;
}

C. Problem for Nazar

D. Stas and the Queue at the Buffet

sb微扰。我觉得比A还sb。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e5+_;struct node{int a,b;}p[maxn];
bool cmp(node n1,node n2){return n1.a-n1.b>n2.a-n2.b;}
int main()
{int n;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d%d",&p[i].a,&p[i].b);sort(p+1,p+n+1,cmp);LL ans=0;for(int i=1;i<=n;i++){ans+=(LL)(i-1)*p[i].a+(LL)(n-i)*p[i].b;}printf("%lld\n",ans);return 0;
}

D. Stas and the Queue at the Buffet

E. Number of Components

这个E岂不是搞笑的??明明O(n)还放1e5

考虑已经得到前i-1个点的贡献,现在加入i这个点,假如a[i]不在[l,r]里面或a[i],a[i-1]都在[l,r]里面它没有贡献,否则就会产生贡献。

第二天rose_king又给出了一个更直观的做法:因为联通块数=总点数-被删的边数,答案就是=总点数-被删的边数-不在[l,r]的点数

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e5+_;int a[maxn];
int main()
{int n;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);LL ans=(LL)(a[1]-1)*(n-a[1])+n; int L,R;for(int i=2;i<=n;i++){if(a[i]==a[i-1])continue;if(a[i]>a[i-1]){L=a[i]-1-a[i-1],R=n-a[i];}else if(a[i]<a[i-1]){L=a[i]-1,R=a[i-1]-1-a[i];}ans+=(LL)L*R+L+R+1;}printf("%lld\n",ans);return 0;
}

E. Number of Components

F. Sonya and Informatics

这个F也是我有问题,看错了一发题意浪费了半个小时,然后脑子不清醒写了个假的,其实只要设f[i]表示在正确位置的1的个数为i然后明显矩乘优化就完事了

咕了

这几场手速都是极大的劣势

天天又看错题

还很慢热,写完模拟才有点做题的感觉

总之就是菜鸡一个

不过没fail题算是有点安慰吧

转载于:https://www.cnblogs.com/AKCqhzdy/p/10735269.html

Codeforces Round #553 (Div. 2) 题解相关推荐

  1. Codeforces Round #514 (Div. 2)题解

    Codeforces Round #514 (Div. 2)题解 A 喵,直接模拟. B 枚举所有盖章时的,合法的,左上角的位置.能盖的话就盖一下.最后check一下图案是否相等即可 C 一轮一轮的扔 ...

  2. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  3. 【算法题解】Codeforces Round #817 (Div. 4)题解

    文章目录 Codeforces Round #817 (Div. 4)题解 A. Spell Check B. Colourblindness C. Word Game D. Line E. Coun ...

  4. Codeforces Round #747 (Div. 2)题解

    Codeforces Round #747 (Div. 2)题解 (本博客将持续更新以后每场CF div2的题解,喜欢ACM.OI的小伙伴记得点个关注哟) 昨天夜晚刷网络流刷入迷了,渐渐就忘记了我还要 ...

  5. Codeforces Round #789 (Div. 2)题解

    Codeforces Round #789 (Div. 2)题解 A. Tokitsukaze and All Zero Sequence 原题链接 算法标签 贪心 排序 思路 情况一:数组存在零 → ...

  6. Codeforces Round #748 (Div. 3) 题解 完整A~G

    Codeforces Round #748 (Div. 3) 题解 A. Elections 题意 已知竞选中三个候选人的当前得票数 a , b , c a,b,c a,b,c,现在可以增加任何一个人 ...

  7. Codeforces Round #533 (Div. 2)题解

    link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...

  8. Codeforces Round #734 (Div. 3) 题解

    Hello大家好,今天给大家带来的是 Codeforces Round #734 (Div. 3) 的全题目讲解. 本文链接:https://www.lanqiao.cn/questions/2040 ...

  9. Codeforces Round #462 (Div. 2)题解

    Codeforces Round #462 (Div. 2) B题--我固执的认为1e18是18位数,导致被hack,花了20分钟才检查出这个错误,很僵硬 Codeforces 934C 题意 给定一 ...

  10. Codeforces Round #441 Div. 2题解

    A.直接判断相邻的边是不是最短边 是就来回走 不然就走一条第二的然后再来回走 #include<cstdio> #include<cstring> #include<al ...

最新文章

  1. 替代TabActivity,底部菜单主框架搭建
  2. python语言入门详解-python初级教程:入门详解
  3. SQL Server 2008, 2008 R2, 2012 and 2014 完全支持TLS1.2加密传输
  4. php连接mysql的区别吗_php连接mysql之mysql_connect()与mysqli_connect()的区别
  5. Python(6):工程组织结构
  6. Dotnet Core应用跨框架版本运行
  7. 2019.01.26【NOIP普及组】模拟赛C组总结
  8. .Net DES加密解密(不带向量)
  9. python装饰器函数执行后日志_python 装饰器理解
  10. 小程序 | 云函数获取用户openid
  11. Jenkins 学习总结(8)—— Jenkins X 入门实践
  12. 【Q】【POJ 2560】【POJ 2031】
  13. ubuntu 下安装配置LAMP
  14. 思科 GNS3 配置 NAT 端口映射
  15. 【python自动化第十篇:】
  16. 哥德巴赫猜想—初等数论课后习题
  17. Cgroup 资源配置方法----------Control Groups------Docker通过 Cgroup 来控制容器使用的资源配额
  18. 两种播放m3u8链接的方法
  19. Vue——组件化开发
  20. 数字图像处理(三)图像复原(噪声生成,噪声滤波器,逆滤波,维纳滤波,有约束最小二乘恢复)

热门文章

  1. 运动目标跟踪(八)--时空上下文(STC)跟踪原理
  2. python xlutils教程_python xlutils复制表格使用方法
  3. pythontkinter使按钮失效_python2.7为什么点击了quot;开始quot;按钮后,tkinter上的按钮,图中红色部分,再也点不动了? - SegmentFault 思否...
  4. 分库分表 or 中间件 ?
  5. ZeroMQ使用教程
  6. Codeforces 893 D Credit Card 贪心 思维
  7. error 1044 (42000):access denied for user ''@'localhost' to database 'mysql'
  8. 第五次作业--原型设计(结对)
  9. JavaScript核心语法学习部分(七)
  10. mysql优化概述2