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

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. DB2和MySQL常用SQL整理

    1.Truncate删除表中所有数据 truncate table USER immediate; 说明:Truncate是一个能够快速清空资料表内所有资料的SQL语法.并且能针对具有自动递增值的字段 ...

  2. Linux学习之十七-配置Linux简单的脚本文件自启动

    配置Linux简单的脚本文件自启动 在Linux中使用shell脚本解决一些问题会比单独执行多条命令要有效率,脚本文件规定命名以.sh结尾,最基本的规则就是其内容是命令,想要脚本文件开机自启动,就需要 ...

  3. 15、Spring Boot使用Druid和监控配置【从零开始学Spring Boot】

    转载:http://blog.csdn.net/linxingliang/article/details/52001740目录(?)[-] 1添加Maven依赖 或jar包 2配置数据源相关信息 3 ...

  4. 每天一个命令 ls

    默认建立一个目录时初始硬连接数为2若该目录下有几个目录就会再增加几个连接数 ls -li 查看inode信息 ls -al 查看所有文件信息 ls -lR 查看目录下目录下的文件(递归显示目录下的文件 ...

  5. AudioSession/AudioCaptureSession的分析与使用

    这个是AudioSession的结构图: 前一个部分已经介绍了AVFoundation对音频录制.播放的一种方法,以下再介绍第二种: AVCaptureSession 用这个类的长处在什么地方呢? ( ...

  6. jquery:after append appendTo三个函数的区别

    1.查找元素节点      var $li = $(“ul li:eq(0)”);//获取ul标记下的第一个li,也可以写成 $(“#ulID li:eq(0)”);    2.查找元素属性 利用jq ...

  7. HTTP头解读

    Http协议定义了很多与服务器交互的方法,最基本的有4种,分别是GET.POST.PUT.DELETE.一个URL地址用于描述一个网络上的资源, 而HTTP中的GET.POST.PUT. DELETE ...

  8. 再说java final变量

    http://blog.csdn.net/axman/article/details/1460544 从jdk1.0到今天,JAVA技术经过十余年的发展,技术上已经发生了巨大的变化.但final变量的 ...

  9. bit-map再显身手:test.txt中有42亿个无符号整数, 求不存在于test.txt中的最小无符号整数。限制: 可用内存为600MB.

    先看看这个题目:test.txt中有42亿个无符号整数, 求不存在于test.txt中的最小无符号整数. 限制: 可用内存为600MB. 又是大数据. 看到42亿, 有灵感没? 要知道, 2的32次方 ...

  10. 产生N个不重复的随机数的快速算法

    //seed array ,,,,,,,,,}; //随机数个数 ; //结果存放在里面 ]; ; i < N; i++) { //从剩下的随机数里生成 , startArray.length ...