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

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. 字符集研究之多字节字符集和unicode字符集

    作者:朱金灿 来源:http://blog.csdn.net/clever101 本文简介计算机中两大字符集:多字节字符集和unicode字符集的出现及关系. 首先我们须要明确的是计算机是怎样找到字符 ...

  2. sql 从另外一张表查询数据存入本表. (有关联的)

    UPDATE friends INNER JOIN users ON friends.friendid=users.userid SET friends.friendname=users.userna ...

  3. vue Object.freeze() 优化

    参考自:https://segmentfault.com/a/1190000006191558 Object.freeze()是ES5新增的特性,可以冻结一个对象,防止对象被修改. vue 1.0.1 ...

  4. Shell脚本之:while

    while循环用于不断执行一系列命令,也用于从输入文件中读取数据:命令通常为测试条件.其格式为: while command do Statement(s) to be executed if com ...

  5. IP、操作系统、移动OS

    IP IP地址 = 网络地址 + 主机地址/IP地址 = 网络地址 + 子网地址 + 主机地址. DNS :进行域名解析的服务器.             比如,sina.com(是域名).其实是一个 ...

  6. RF--- selenium

  7. Gson把对象转成json格式的字符串

    近期在做一个java web service项目,须要用到jason,本人对java不是特别精通,于是開始搜索一些java平台的json类库. 发现了google的gson.由于之前对于protoco ...

  8. java ConcurrentHashMap 初识

    “ConcurrentHashMap是一个线程安全的哈希表“,但是不允许key和value为空: HashTable和ConcurrentHashMap都是线程安全的,但是HashTable是同步容器 ...

  9. we are experimenting with a new init system and it is fun

    http://0pointer.de/blog/projects/systemd.html Rethinking PID 1 If you are well connected or good at ...

  10. 给定一颗完全二叉树,给每一层添加上next的指针,从左边指向右边

    给你机会发出声音,但是不给你机会证明高层的决定是错的 RT: 时间复杂度O(n) 空间复杂度O(1)  原理就是有指针指向父节点和当前的节点,左孩子必指向右孩子,右孩子必指向父节点的下一个节点的左孩子 ...