A.3*3讨论即可,注意正方形套圆套三角形只有6个点。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,ans,a[N]; int main(){
scanf("%d",&n);
rep(i,,n) scanf("%d",&a[i]);
rep(i,,n){
if ((a[i-]== && a[i]==) || (a[i-]== && a[i]==)){ puts("Infinite"); return ; }
if ((a[i-]== && a[i]==) || (a[i-]== && a[i]==)) ans+=;
if ((a[i-]== && a[i]==) || (a[i-]== && a[i]==)) ans+=;
if (i>= && a[i-]== && a[i-]== && a[i]==) ans--;
}
printf("Finite\n%d\n",ans);
return ;
}

A

B.相同字符显然放在一起,先统计一共有几种字符。若一种,直接输出。若两种,若两字符相邻则无解否则直接输出。若三种,若三字符均相邻则无解,否则132或213总有一种可行。若四种,3142即可。四种以上,前一半和后一半间隔着输出即可。如n=6时输出142536。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
char s[N];
int T,n,cnt[N],w[N]; int main(){
for (scanf("%d",&T); T--; ){
scanf("%s",s+); n=strlen(s+); int d=;
rep(i,,) cnt[i]=;
rep(i,,n) cnt[s[i]-'a']++;
rep(i,,) if (cnt[i]) w[++d]=i;
if (d==){ puts(s+); continue; }
if (d==){
if (w[]+==w[]) puts("No answer");
else{
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a'); puts("");
}
continue;
}
if (d==){
if (w[]+==w[]){
if (w[]+==w[]) puts("No answer");
else{
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a'); puts("");
}
}else{
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a'); puts("");
}
continue;
}
if (d==){
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a');
rep(i,,cnt[w[]]) putchar(w[]+'a');
puts("");
continue;
}
rep(i,,(d+)/){
rep(j,,cnt[w[i]]) putchar(w[i]+'a');
if (i+(d+)/<=d) rep(j,,cnt[w[i+(d+)/]]) putchar(w[i+(d+)/]+'a');
}
puts("");
}
return ;
}

B

C.二分答案,设二分值为mid,则将i和n-mid+i依次配对,判断配对数是否>=mid。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,z,ans,a[N],b[N]; bool chk(int mid){
int res=;
rep(i,,mid) if (a[n-mid+i]-a[i]>=z) res++;
return res>=mid;
} int main(){
scanf("%d%d",&n,&z);
rep(i,,n) scanf("%d",&a[i]);
sort(a+,a+n+); int L=,R=n/;
while (L<R){
int mid=(L+R+)>>;
if (chk(mid)) L=mid; else R=mid-;
}
printf("%d\n",L);
return ;
}

C

D.一种方法是,先对每个点BFS出它所在1连通块的大小bel[x],然后再对每个点BFS出它所在0连通块并将块中的点的bel累加起来得到答案。

还有一种是树上DP,f[x][0/1]表示x往下只走0边/先走0边再走1边,的方案数。g[x][0/1]表示x往下只走1边/先走1边再走0边,的方案数。在每个点上枚举有多少以它为路径最高点的合法路径。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=; int n,p[N],t;
ll f[N][],g[N][],ans;
struct data{int to,nxt,len; }E[N<<];
void add(int x,int y,int z){t++;E[t].to=y,E[t].nxt=p[x],E[t].len=z,p[x]=t;} void dfs(int k,int from){
f[k][]=; g[k][]=;
for (int i=p[k];i;i=E[i].nxt)
if (E[i].to!=from){
dfs(E[i].to,k);
if (E[i].len==) f[k][]+=f[E[i].to][];
else f[k][]+=f[E[i].to][]+f[E[i].to][];
if (E[i].len==) g[k][]+=g[E[i].to][];
else g[k][]+=g[E[i].to][]+g[E[i].to][];
}
for (int i=p[k];i;i=E[i].nxt)
if (E[i].to!=from){
int x=f[k][],y=f[k][];
if (E[i].len==) x-=f[E[i].to][];
else y-=f[E[i].to][]+f[E[i].to][];
if (E[i].len==) ans+=x*g[E[i].to][];
ans+=x*g[E[i].to][];
if (E[i].len==) ans+=y*g[E[i].to][];
}
ans+=f[k][]+f[k][]-;
} int main(){
scanf("%d",&n);
rep(i,,n){
int x,y,z; scanf("%d%d%d",&x,&y,&z);
add(x,y,z),add(y,x,z);
}
dfs(,); cout<<ans<<endl;;
return ;
}

方法二

E.从小到大插入p,每次以当前p[x]为区间最大值的合法区间数,就是x左边的已插入的连续段和右边已插入的连续段的信息合并。这个可以用set启发式合并支持查询与合并,为了快速寻找某个位置被合并到哪了需要用到并查集,复杂度两个log。

 #include<set>
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std; const int N=;
int n,ans,a[N],id[N],fa[N];
set<int>S[N]; bool cmp(int x,int y){ return a[x]<a[y]; }
int get(int x){ return fa[x]==x ? x : fa[x]=get(fa[x]); } int main(){
scanf("%d",&n);
rep(i,,n) scanf("%d",&a[i]),id[i]=fa[i]=i,S[i].insert(a[i]);
sort(id+,id+n+,cmp);
rep(i,,n){
int x=id[i],p=get(x-),q=get(x+);
if (x== || x==n || a[x-]>a[x] || a[x+]>a[x]){
if (x> && a[x-]<a[x]) S[p].insert(a[x]),fa[x]=p;
if (x<n && a[x+]<a[x]) S[q].insert(a[x]),fa[x]=q;
continue;
}
if (S[p].size()>S[q].size()) swap(p,q);
set<int>::iterator it;
for (it=S[p].begin(); it!=S[p].end(); it++)
if (S[q].find(a[x]-(*it))!=S[q].end()) ans++;
for (it=S[p].begin(); it!=S[p].end(); it++) S[q].insert(*it);
S[q].insert(a[x]); fa[p]=fa[x]=q;
}
printf("%d\n",ans);
return ;
}

E

F.枚举win的时候是第几次拿数以及这个数是几。f[i][j]表示数j作为第i个拿出来的数且前i个数都严格递增的概率。根据这个再要求第i+1个数也为j,再之后的数随便放即可。

 #include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std; const int N=,mod=;
int n,x,ans,f[N][N],cnt[N],inv[N]; int main(){
scanf("%d",&n); inv[]=;
rep(i,,n) scanf("%d",&x),cnt[x]++;
rep(i,,n) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
rep(i,,n){
int s=(i==);
rep(j,,n){
f[i][j]=1ll*s*cnt[j]%mod*inv[n-i+]%mod;
if (cnt[j]>) ans=(ans+1ll*f[i][j]*(cnt[j]-)%mod*inv[n-i]%mod)%mod;
s=(s+f[i-][j])%mod;
}
}
printf("%d\n",ans);
return ;
}

F

Educational Codeforces Round 64 (Div. 2)的更多相关文章

  1. Educational Codeforces Round 64 (Rated for Div. 2)题解

    Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...

  2. Educational Codeforces Round 64 部分题解

    Educational Codeforces Round 64 部分题解 不更了不更了 CF1156D 0-1-Tree 有一棵树,边权都是0或1.定义点对\(x,y(x\neq y)\)合法当且仅当 ...

  3. Educational Codeforces Round 64(ECR64)

    Educational Codeforces Round 64 CodeForces 1156A 题意:1代表圆,2代表正三角形,3代表正方形.给一个只含1,2,3的数列a,ai+1内接在ai内,求总 ...

  4. Educational Codeforces Round 64部分题解

    Educational Codeforces Round 64部分题解 A 题目大意:给定三角形(高等于低的等腰),正方形,圆,在满足其高,边长,半径最大(保证在上一个图形的内部)的前提下. 判断交点 ...

  5. Educational Codeforces Round 84 (Div. 2)

    Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性 ...

  6. Educational Codeforces Round 64 (Rated for Div. 2) A,B,C,D,E,F

    比赛链接: https://codeforces.com/contest/1156 A. Inscribed Figures 题意: 给出$n(2\leq n\leq 100)$个数,只含有1,2,3 ...

  7. Educational Codeforces Round 64 (Rated for Div. 2) (线段树二分)

    题目:http://codeforces.com/contest/1156/problem/E 题意:给你1-n  n个数,然后求有多少个区间[l,r] 满足    a[l]+a[r]=max([l, ...

  8. Educational Codeforces Round 64 (Rated for Div. 2)D(并查集,图)

    #include<bits/stdc++.h>using namespace std;int f[2][200007],s[2][200007];//并查集,相邻点int find_(in ...

  9. Educational Codeforces Round 64(Unrated for Div.1+Div. 2)

    什么垃圾比赛,A题说的什么鬼楞是没看懂.就我只会BD(其实C是个大水题二分),垃圾游戏,技不如人,肝败吓疯,告辞,口胡了E就睡觉了. B 很容易发现,存在一种方案,使得相同字母连在一起,然后发现,当字 ...

随机推荐

  1. VS2008下LibTomCrypt 1.17的编译和使用《转》

    文章出处:http://blog.csdn.net/delphiwcdj/article/details/6298820 具体步骤如下: (1) 下载tomcrypt tomcrypt 1.17 VS ...

  2. 基因表达半衰期 | mRNA Half-Life

    做单细胞RNA-seq分析,自然就能想到我们测到的其实是一个概率学的东西,就像女士品茶里的酵母的泊松分布一样. 真实的细胞里,一切都是连续的,从DNA到mRNA到蛋白,是有一个时间间隔的,每一个pro ...

  3. onenote 每天输入网络密码

    1.问题:只局限 内网 笔记本的弹出输入远程内网服务器用户名密码的情况,每次重启电脑后又会要求输入,否则同步失败 2.解决 控制面板-windows用户-凭据管理器-添加凭据-从上到下一次输入  ip ...

  4. win10: windows+E 改回打开我的电脑

    之前习惯使用windows+E来打开我的电脑,用了win10之后按windows+E打开的却是“快速访问”文件夹,很不习惯,可用下列办法改回: 1.打开“查看”选项卡,选择”选项“按钮. 2.在“常规 ...

  5. Oracle 查询表注释以及字段注释

    Oracle 查询表注释以及字段注释 --表字段信息 select * from all_tab_columns a where a.TABLE_NAME='T_X27_USER'; --表注释信息 ...

  6. 000 基于Spring boot发送邮件

    发送邮件的程序,使用QQ的服务器,经过测试,完全可行.可复现 一:准备工作 1.找到账号的授权码 这个是程序需要使用的. 在设置中查找. 2.新建项目的目录 二:完整的程序代码 1.pom.xml & ...

  7. SpringCloud-Eureka配置instanceId显示IP

    eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ instance: preferIpAddress: tr ...

  8. springboot rabbitMQ 死信对列 实现消息的可靠消费

    1 引入 maven 依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifac ...

  9. [原]Arcgis arcmap修改图元配色

    感谢南师大的“深爱”提供的帮助 1.选择识别工具,点击海洋,确定海洋色块的color index为255 2.右键tif选择属性 3.选择分页栏中的符号化(Symbology) 4.找到对应的Labe ...

  10. QDateTime获取当前时间的时间戳

    QdateTime获取当前时间的时间戳作为图片名 QDateTime qdt1 = QDateTime::currentDateTime();QString timeStr = qdt1.toStri ...