因为这次难得不在十点半(或是更晚),大家都在打,然后我又双叒叕垫底了=。=

自己对时间的分配,做题的方法和心态还是太蒻了,写的时候经常写一半推倒重来。还有也许不是自己写不出来,而是在开始写之前就觉得自己写不出来

多打CF

A.Sea Battle

讨论.jpg

也有式子的解法,我没想

B.Draw

讨论失败.jpg

(写题顺序:ADFC,没有B)

讨论个**,转化成线段求交,答案就是$\sum max(0,min(x,y)-max(lstx,lsty)+(lstx!=lsty))$,记得加上一开始的1

C.Birthday

赛场降智->枚举两边$n^2$+排序后中间轮着放检查$n$->$n^3$睿智算法

正确答案->不知为啥还要枚举,排序以后直接轮着放->$n\log n$

D.Gourmet choice

并查集+拓扑排序

 #include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=,M=;
int num[N],aset[N],que[N],bel[N];
int p[N],noww[M],goal[M],deg[N];
int n,m,f,b,t1,t2,cnt,tot,ff;
char rd[][];
int Finda(int x)
{
return x==aset[x]?x:aset[x]=Finda(aset[x]);
}
void Link(int f,int t)
{
noww[++cnt]=p[f],deg[t]++;
goal[cnt]=t,p[f]=cnt;
}
int main ()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n+m;i++) aset[i]=i;
for(int i=;i<=n;i++)
{
scanf("%s",rd[i]+);
for(int j=;j<=m;j++)
if(rd[i][j]=='=')
aset[Finda(i)]=Finda(j+n);
}
for(int i=;i<=n+m;i++) bel[i]=Finda(i);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
{
if(rd[i][j]=='<') Link(bel[i],bel[j+n]);
if(rd[i][j]=='>') Link(bel[j+n],bel[i]);
}
for(int i=;i<=n+m;i++)
if(!deg[i]) que[++b]=i,num[i]=;
while(f<=b)
{
int tn=que[f++];
for(int i=p[tn];i;i=noww[i])
if(!(--deg[goal[i]]))
que[++b]=goal[i],num[goal[i]]=num[tn]+;
}
for(int i=;i<=n+m;i++) if(deg[i]) printf("No"),exit(); puts("Yes");
for(int i=;i<=n;i++) printf("%d ",num[bel[i]]); puts("");
for(int i=n+;i<=n+m;i++) printf("%d ",num[bel[i]]);
return ;
}

E.String Multiplication

请讨论.jpg

答案只和最大子段,前缀连续和后缀连续有关,枚举哪个字符作为答案之后再统计就比较简单了

但是仍然有很多细节=。=

#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=;
string str[N]; long long ans;
int main()
{
int n; cin>>n;
for(int i=;i<=n;i++)
cin>>str[i];
for(int i='a';i<='z';i++)
{
long long maxi=;
for(int j=;j<=n;j++)
{
int len=str[j].size();
long long lst=,tmp=,pre=,suf=;
for(int k=;k<len;k++)
(str[j][k]==i)?lst=max(lst,++tmp):tmp=;
if(lst||maxi)
{
for(int k=;k<len;k++)
if(str[j][k]==i) pre++;
else break;
for(int k=len-;~k;k--)
if(str[j][k]==i) suf++;
else break;
if(lst==len) maxi=(maxi+)*lst+maxi;
else maxi=maxi?max(lst,pre+suf+):lst;
}
}
ans=max(ans,maxi);
}
printf("%lld",ans);
return ;
}

F.Asya And Kittens

并查集维护小猫之间的连通性,同时维护每只小猫的下一只小猫和当前小猫链里最后一只小猫是谁。

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=;
int n,st,t1,t2,cnt;
int aset[N],nxt[N],endp[N];
int Finda(int x)
{
return x==aset[x]?x:aset[x]=Finda(aset[x]);
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) aset[i]=endp[i]=nxt[i]=i;
for(int i=;i<n;i++)
{
scanf("%d%d",&t1,&t2);
int t3=Finda(t1),t4=Finda(t2);
aset[t3]=t4,nxt[endp[t4]]=t3,endp[t4]=endp[t3];
}
for(int i=;i<=n;i++)
if(Finda(i)==i) {st=i; break;}
while(nxt[st]!=st)
printf("%d ",st),st=nxt[st];
printf("%d",st);
return ;
}

G.Most Dangerous Shark

单调栈优化DP,代码咕咕了

放一个WinnieChen的代码

Codeforces Round #541的更多相关文章

  1. Codeforces Round #541 (Div. 2)

    Codeforces Round #541 (Div. 2) http://codeforces.com/contest/1131 A #include<bits/stdc++.h> us ...

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

    不知道该更些什么 随便写点东西吧 https://codeforces.com/contest/1131 ABC 太热了不写了 D 把相等的用并查集缩在一起 如果$ x<y$则从$ x$往$y$ ...

  3. Codeforces Round #541 (Div. 2) D(并查集+拓扑排序) F (并查集)

    D. Gourmet choice 链接:http://codeforces.com/contest/1131/problem/D 思路: =  的情况我们用并查集把他们扔到一个集合,然后根据 > ...

  4. Codeforces Round #541 (Div. 2) (A~F)

    目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路 ...

  5. Codeforces Round #541 (Div. 2) G dp + 思维 + 单调栈 or 链表 (连锁反应)

    https://codeforces.com/contest/1131/problem/G 题意 给你一排m个的骨牌(m<=1e7),每块之间相距1,每块高h[i],推倒代价c[i],假如\(a ...

  6. Codeforces Round #541 (Div. 2) E 字符串 + 思维 + 猜性质

    https://codeforces.com/contest/1131/problem/D 题意 给你n个字符串,字符串长度总和加起来不会超过1e5,定义字符串相乘为\(s*s1=s1+s[0]+s1 ...

  7. Codeforces Round #541 (Div. 2) D 并查集 + 拓扑排序

    https://codeforces.com/contest/1131/problem/D 题意 给你一个n*m二维偏序表,代表x[i]和y[j]的大小关系,根据表构造大小分别为n,m的x[],y[] ...

  8. Codeforces Round #541 (Div. 2) C.Birthday

    链接:https://codeforces.com/contest/1131/problem/C 题意: 求给的n个数,相邻差值最小的排列方式.1-n相邻. 思路: sort后隔一个取一个,取到底后再 ...

  9. Codeforces Round #541 (Div. 2) B.Draw!

    链接:https://codeforces.com/contest/1131/problem/B 题意: 给n次足球比分,求存在平局的机会. 思路: 结构体存储,unique后,判断是否有分数交叉. ...

  10. Codeforces Round #541 (Div. 2) A.Sea Battle

    链接:https://codeforces.com/contest/1131/problem/A 题意: 给两个矩形,一个再上一个在下,求两个矩形合并的周围一圈的面积. 思路: 因为存在下面矩形宽度大 ...

随机推荐

  1. Python3入门(九)——面向对象OOP高级编程

    一.使用__slots__限制属性绑定 动态绑定实例的方法: class Person(object): def run(self): print("奔跑吧!") p1 = Per ...

  2. Spring3 访问静态资源

    <mvc:resources location="/jquery/" mapping="/jquery/**"/> <mvc:resource ...

  3. JavaEE笔记(十四)

    #SSH配置文件整合笔记实例 spring-BaseBean.xml <?xml version="1.0" encoding="UTF-8"?> ...

  4. MiZ702学习笔记8——让MiZ702变身PC的方法

    首先你需要一个安装好的linux系统,这里我用的是Ubuntu的虚拟机.VMWare的话,选择较高版本的成功率会高些(当然根据自己电脑的配置进行选择). 打开Ubuntu的虚拟机,找到一个叫做Disk ...

  5. it面试技巧

    一:请你自我介绍一下你自己? 回答提示:一般人回答这个问题过于平常,只说姓名.年龄.爱好.工作经验,这些在简历上都有.其实,企业最希望知道的是求职者能否胜任工作,包括:最强的技能.最深入研究的知识领域 ...

  6. Security7:管理SQL Server Agent的权限

    SQL Server Agent对象包括警报(Alert),操作员(Operator),Job,调度(Schedule)和代理(Proxy),SQL Server使用msdb系统数据库管理Agent ...

  7. Asp.net中汉字转换成为拼音

    1.应用场景 将汉字转换为拼音(eg:"我爱你"--->"WOAINI") 取各个汉字的首字母(eg:"我是中国人"--->&q ...

  8. NAND Flash底层原理,SLC MLC TLC比较

    NAND-Flash 的存储原理 固态硬盘最小单元的基本架构如下: 我们知道计算机中所有的信息储存最终都必须回归到 0与1,原则上,只要存储单元能提供两种或两种以上可供辨识的状态,便可以拿来纪录数据. ...

  9. .NET Core容器化开发系列(零)——计划

    .NET Core相当完善的跨平台特性以及其轻量化的底层接口为我们能顺畅进行微服务开发提供了非常棒的基础. 作为支撑微服务最常见的基础技术--容器化将是本系列的核心内容. 接下来我计划用一个月左右的时 ...

  10. 高精度加法--C++

    高精度加法--C++ 仿照竖式加法,在第一步计算的时候将进位保留,第一步计算完再处理进位.(见代码注释) 和乘法是类似的. #include <iostream> #include < ...