A

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 105
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int main()
{
int i,j,k;
cin>>s;
k = strlen(s);
int ans = ,g=;
for(i = ; i < k ;i++)
{
if(s[i]!=s[i-])
{
g = ;
ans++;
}
else g++;
if(g>)
{
g = ;
ans++;
}
//cout<<ans<<" "<<g<<" "<<s[i]<<endl;
}
cout<<ans<<endl;
return ;
}

B

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 5050
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int a[N],f[N];
int main()
{
int i,j,n,k;
cin>>n;
for(i =;i <= n; i++)cin>>a[i];
for(i = ;i <= n ;i++)
{
f[a[i]] = ;
}
int ans=;
for(i = ; i<= n; i++)
if(!f[i]) ans++;cout<<ans<<endl;
return ;
}

C

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct node
{
int x,y;
}p[N];
bool cmp(node a,node b)
{
return a.x<b.x;
}
int main()
{
int i,j,n;
cin>>n;
for(i = ; i <= n ;i++)
cin>>p[i].x>>p[i].y;
sort(p+,p+n+,cmp);
int mm = ,ans=;
for(i = ; i <= n ;i ++)
{
if(p[i].y<mm)
ans++;
mm = max(mm,p[i].y); }
cout<<ans<<endl;
return ;
}

D

dp  先预处理出来i-j距离回文串所差的步数  然后D出1-k所需最少的步数 记录一下路径 最后输出

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 505
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int dp[][],o[][],e[][];
int p[];
int dfs(int i,int j)
{
int a,b;
int o1 = ;
int ii = i,jj = j;
while(ii<jj)
{
if(s[ii]!=s[jj]) o1++;
ii++,jj--;
}
return o1;
}
int main()
{
int i,j,n,kk,k,g;
for(i = ;i <= ; i++)
for(j = ; j <= ; j++)
dp[i][j] = INF;
cin>>s;
kk = strlen(s);
cin>>k;
for(i = ;i < kk ;i++)
for(j = i ; j < kk ;j++)
o[i][j] = dfs(i,j);
for(i = ; i < kk; i++)
{
dp[i][] = o[][i];
}
for(i = ;i < kk ;i++)
for(j = ; j <= min(i+,k) ; j++)
for(g = ; g < i ; g++)
{
if(dp[i][j]>dp[g][j-]+o[g+][i])
{
dp[i][j] = dp[g][j-]+o[g+][i];
e[i][j] = g;
}
}
int minz = INF,x;
for(i = ; i <= k ;i++)
{
if(minz>dp[kk-][i])
{
minz = dp[kk-][i];
x = i;
}
}
cout<<minz<<endl;
if(x==)
{
for(i = ; i < kk/ ; i++)
printf("%c",s[i]);
for(i = (kk-)/ ; i >= ; i--)
printf("%c",s[i]);
return ;
}
g = ;
int ki = kk-;
while(x!=)
{
ki = e[ki][x];
p[g++] = ki;
x--;
}
sort(p,p+g);
for(i = ;i <= p[]/ ; i++)
printf("%c",s[i]);
if(p[])
{
for(i = (p[]-)/ ; i >= ; i--)
printf("%c",s[i]);
}
for(i = ; i < g- ;i++)
{
printf("+");
for(j = p[i]+ ;j <= p[i]+(p[i+]-p[i]+)/ ; j++)
cout<<s[j];
for(j = p[i]+(p[i+]-p[i])/ ;j >= p[i]+ ; j--)
cout<<s[j];
}
if(p[g-]+<kk)
printf("+");
for(i = p[g-]+ ; i <= p[g-]+(kk-p[g-])/ ; i++)
cout<<s[i];
for(i = p[g-]+(kk-p[g-]-)/ ; i >= p[g-]+ ; i--)
cout<<s[i];
cout<<endl;
return ;
}

E

元音-1 辅音+2 开数组sum[i]存前i项和  也就是找最大段(i,j)使sum[j]-sum[i]>=0

这样只存下降的sum数组即可  因为上升的的某个g事不需要的 二分查找第一个小于等于sun[i]的位置 取最大

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 200010
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N];
int sum[N];
struct node
{
int a,po;
}p[N];
int bfind(int l,int h,int k)
{
int m;
while(l<h)
{
m = (l+h)>>;
if(p[m].a<k)
h = m;
else if(p[m].a>k)
l = m+;
else return p[m].po;
}
return p[l].po;
}
int judge(char c)
{
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
return ;
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
return ;
return ;
}
int main()
{
int i,j,k;
cin>>s;
k = strlen(s);
int g = ;
for(i = ; i < k ;i++)
{
if(i==)
{
if(judge(s[i]))
sum[] = -;
else
sum[] = ;
p[++g].a = sum[i];
p[g].po = i;
}
else
{
if(judge(s[i]))
sum[i] = sum[i-]-;
else
sum[i] = sum[i-]+;
if(sum[i]<p[g].a)
{
p[++g].a = sum[i];
p[g].po = i;
}
}
}
int ans=,cnt=;
for(i = ; i < k ;i++)
{
if(sum[i]>=)
{
ans = i+;
cnt = ;
}
else
{
int o = i-bfind(,g,sum[i]);
//cout<<o<<" "<<i<<" "<<bfind(1,g,sum[i])<<endl;
if(o>ans)
{
ans = o;
cnt = ;
}
else if(o==ans)
cnt++;
}
}
if(ans)
cout<<ans<<" "<<cnt<<endl;
else
puts("No solution");
return ;
}

Codeforces Beta Round #98 (Div. 2)(A-E)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

随机推荐

  1. HDU 5303 Delicious Apples (贪心 枚举 好题)

    Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Other ...

  2. 【转载】企业服务总线Enterprise service bus介绍

    企业服务总线(Enterprise service bus). 以往企业已经实现了很多服务, 构成了面向服务的架构,也就是我们常说的SOA. 服务的参与双方都必须建立1对1 的联系,让我们回顾一下SO ...

  3. 软件project

    Problem Description Merlin的软件project老师Max布置了开发一个软件的大作业.因为这是一个大型软件.所以单靠Merlin一个人不可能在预订的时间内做完,必须与其它人合作 ...

  4. bash builtin eval

    1 在开始执行eval后面的命令之前eval主要做了哪些事情 1.1 去掉反斜杠的quoting 比如\$ac_optarg,会变成$ac_optarg. 1.2 去掉单引号的quoting 比如: ...

  5. 60年代进程 80年代线程 IPC How the Java Virtual Machine (JVM) Works

    小结: 1. To facilitate communication between processes, most operating systems support Inter Process C ...

  6. Hibernate状态转换

    瞬时态: 对象有new关键字创建,此时还未与Session关联. 持久态: 在执行session.save(bean)或saveOrUpdate()操作后,bean纳入Session的管理范围,这时b ...

  7. YTU 2559: “心脏出血”

    2559: "心脏出血" 时间限制: 1 Sec  内存限制: 128 MB 提交: 5  解决: 2 题目描述 2014年4月,一个开源加密库OpenSSL的严重漏洞" ...

  8. YTU 2912: 圆柱体的C++

    2912: 圆柱体的C++ 时间限制: 1 Sec  内存限制: 128 MB 提交: 333  解决: 133 题目描述 小明的弟弟加入的C++兴趣小组,组长布置的第一个任务就是将已有的C程序改写成 ...

  9. 八.OC基础加强--1.autorelease的用法 2.ARC下内存管理 3.分类(category)4.block的学习

    1.autorelease的用法   1.自动释放池及autorelease介绍 (1)在iOS程序运行过程中,会创建无数个池子,这些池子都是以栈结构(先进后出)存在的. (2)当一个对象调用auto ...

  10. [Usaco2013 DEC] Vacation Planning

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4093 [算法] 对于k个枢纽 , 分别在正向图和反向图上跑dijkstra最短路 , ...