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

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=; char ss[]; int a[];
int getdis(int x,int y)
{
if(x>y)swap(x,y);
return min(y-x,x+-y);
}
int main()
{
int n,m;
scanf("%d%s",&n,ss+);
for(int i=;i<=n;i++)a[i]=ss[i]-'A'+; int mn=(<<);
for(int i=;i<=n-;i++)
{
mn=min(mn,getdis(a[i],)+getdis(a[i+],)+getdis(a[i+],)+getdis(a[i+],));
}
printf("%d\n",mn); return ;
}

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=; int a[maxn][maxn];
bool f[maxn][];int d[maxn][],fr[maxn][]; int as[maxn];
int main()
{
int n,m,mx=;
scanf("%d%d",&n,&m);
f[][]=true;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
scanf("%d",&a[i][j]),mx=max(mx,a[i][j]); while(mx!=(mx&-mx))mx-=(mx&-mx);
mx<<=;
if(mx==)mx=; for(int i=;i<n;i++)
for(int zt=;zt<mx;zt++)
if(f[i][zt])
{
for(int j=;j<=m;j++)
f[i+][zt^a[i+][j]]=true,d[i+][zt^a[i+][j]]=j,fr[i+][zt^a[i+][j]]=zt;
} for(int zt=;zt<mx;zt++)
if(f[n][zt])
{
puts("TAK");
for(int i=n;i>=;i--)
{
as[i]=d[i][zt],zt=fr[i][zt];
}
for(int i=;i<=n;i++)printf("%d ",as[i]);
puts("");return ;
}
puts("NIE"); return ;
}

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+;
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==)return ;
int op=; LL i,step=,ost=,est=,ret=;
for(i=;i<=n;i<<=)
{
if(step+i>=n)break;
if(op==)
{
LL ed=ost+*(i-);
ret=ad(ret,(ost+ed)%mod*(i%mod)%mod*(mod/+)%mod);
ost=ed+;
}
else
{
LL ed=est+*(i-);
ret=ad(ret,(est+ed)%mod*(i%mod)%mod*(mod/+)%mod);
est=ed+;
}
op^=;
step+=i;
}
if(op==)
{
LL ed=ost+*(n-step-);if(ed%==)ed--;
ret=ad(ret,(ost+ed)%mod*((n-step)%mod)%mod*(mod/+)%mod);
}
else
{
LL ed=est+*(n-step-);if(ed%==)ed--;
ret=ad(ret,(est+ed)%mod*((n-step)%mod)%mod*(mod/+)%mod);
} return ret;
} int main()
{
LL l,r;
scanf("%lld%lld",&l,&r);
printf("%lld\n",re(solve(r),solve(l-))); return ;
}

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=;i<=n;i++)
scanf("%d%d",&p[i].a,&p[i].b);
sort(p+,p+n+,cmp); LL ans=;
for(int i=;i<=n;i++)
{
ans+=(LL)(i-)*p[i].a+(LL)(n-i)*p[i].b;
}
printf("%lld\n",ans); return ;
}

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=;i<=n;i++)scanf("%d",&a[i]); LL ans=(LL)(a[]-)*(n-a[])+n; int L,R;
for(int i=;i<=n;i++)
{
if(a[i]==a[i-])continue;
if(a[i]>a[i-])
{
L=a[i]--a[i-],R=n-a[i];
}
else if(a[i]<a[i-])
{
L=a[i]-,R=a[i-]--a[i];
}
ans+=(LL)L*R+L+R+;
}
printf("%lld\n",ans); return ;
}

E. Number of Components

F. Sonya and Informatics

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

咕了

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

天天又看错题

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

总之就是菜鸡一个

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

Codeforces Round #553 (Div. 2) 题解的更多相关文章

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

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

  2. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  3. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

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

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  5. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  6. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

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

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  8. Codeforces Round #160 (Div. 1) 题解【ABCD】

    Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...

  9. Codeforces Round #383 (Div. 2) 题解【ABCDE】

    Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...

随机推荐

  1. 2017.2.28 activiti实战--第六章--任务表单(一)动态表单

    学习资料:<Activiti实战> 第六章 任务表单(一)动态表单 内容概览:本章要完成一个OA(协同办公系统)的请假流程的设计,从实用的角度,讲解如何将activiti与业务紧密相连. ...

  2. 微信小程序 - 单个题目

    后端传过来的数据,如果通过wx:for遍历出来那就是一个页面全部排下来.... 我的想法就是,页面初始化时设置一个默认值 1/50 就是 index+1 / 50(后端传过来的数组长度),通过控制in ...

  3. 应用设置Setting的实现

    有非常多应用都在iOS设置中有相关的设置.例如以下图:     通过这个设置能够方便的相应用的一些主要的设置进行更改. 要完整的实现这个设置功能,有下面几方面问题须要解决: 1)设置的编写(实现设置的 ...

  4. merge-sorted-array——合并两个有序数组

    Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume th ...

  5. [翻译]MySQL 文档: Control Flow Functions(控制流函数)

    本文翻译自13.4 Control Flow Functions Table 13.6 Flow Control Operators 名称 描述 CASE Case 运算符 IF() if/else ...

  6. .netMVC:Web页面向后台提交数据的方式和选择

    众所周知Web前端页面主要由HTML/CSS/Javascript组成,当要通过与用户的交互实现各种功能时,就需要向后台提交一些数据或者操作.在Web世界里各种实现眼花缭乱,但究其根本,不外乎三种方式 ...

  7. Axure教程:滑动进度条、圆形进度环的复杂交互效果实现方法

    滑动条.进度条.进度环,是产品原型中比较常见的进度展示功能.今天笔者分享的是使用Axure原型工具实现两种进度展示功能中相对复杂的交互效果. 效果一.可拖动.可显示进度值.可计算多个页面均值的滑动进度 ...

  8. Android 虚化图片的方法

    Android 虚化图片 模糊图片 图片毛玻璃效果. 效果如图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaDNjNGxlbm92bw==/font/ ...

  9. Java结束线程的三种方法

    线程属于一次性消耗品,在执行完run()方法之后线程便会正常结束了,线程结束后便会销毁,不能再次start,只能重新建立新的线程对象,但有时run()方法是永远不会结束的.例如在程序中使用线程进行So ...

  10. 结缘mac

    还记得上一次买MacBookPro.是在去年的7月下旬,记得那次是我大学第一次买电脑,那时候刚准备開始研究android.听stormzhang以及android开发界的大佬们对mac开发androi ...