A:链接:http://codeforces.com/contest/825/problem/A

解题思路:

一开始以为是个进制转换后面发现是我想多了,就是统计有多少个1然后碰到0输出就行,没看清题意。。

实现代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int m,i,ans=;
string s;
cin>>m;
cin>>s;
for(i=;i<m;i++){
if(s[i]=='')
ans++;
if(s[i]==''||i==m-){
cout<<ans;
ans=;}
}
if(s[m-]=='')
cout<<"";
cout<<endl;
return ;
}

B.Five-In-a-Row

链接:http://codeforces.com/contest/825/problem/B

解题思路:

就是五子棋,问你能否在空白处填充一个x使其成五子,把字符转换为数字,如果要只差一步成五子,只能是四个‘x’和一个‘.’分别赋值,然后暴力遍历就可以了;

实现代码:

#include<bits/stdc++.h>
using namespace std;
char mp[][];
int id[][];
int main()
{
int i,j,k,ans1,ans2,ans3,ans4,ans,ans5;
memset(id,,sizeof(id));
for(i=;i<=;i++){
for(j=;j<=;j++){
cin>>mp[i][j];
if(mp[i][j]=='X')
id[i][j] = ;
if(mp[i][j]=='O')
id[i][j] = -;
if(mp[i][j]=='.')
id[i][j] = ;
}
}
for(i=;i<=;i++){
for(j=;j<=;j++){
if(id[i][j]==||id[i][j]==){
ans1 = ;ans2=;ans3=;ans4=,ans5=;
for(k=;k<;k++){
if(j<=)
ans1+=id[i][j+k];
if(i<=)
ans2+=id[i+k][j];
if(j<=&&i<=)
ans3+=id[i+k][j+k];
if(i>=&&j>=)
ans4+=id[i-k][j-k];
if(i>=&&j<=)
ans5+=id[i-k][j+k];
}
ans = max(ans1,max(ans2,max(ans3,max(ans4,ans5))));
//cout<<ans<<endl;
if(ans==){
cout<<"YES"<<endl;
return ;
}
}
}
}
cout<<"NO"<<endl;
return ;
}

C:链接:http://codeforces.com/contest/825/problem/C

解题思路:

题目意思有些难懂,要求解决困难,已经解决了k难度的问题,如果待解决的问题ai小于k*2的话可以直接解决,反之需要先达到ai/2,也就是将k不断翻倍直到k*2>=ai.才能解决该问题。而此时已经解决的最大难度为max(k,ai).不断推就行了。看懂题了就很简单了。

实现代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
int n,k,i,maxx = -,a[],ans=;
cin>>n>>k;
for(i=;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
for(i=;i<n;i++){
cout<<k<<" "<<a[i]<<endl;
while(k*<a[i]){
k*=;
ans++;
}
k = max(a[i],k);
}
cout<<ans<<endl;
return ;
}

D.Suitable Replacement

链接:http://codeforces.com/contest/825/problem/D

解题思路:

题目要通过改变?号来求出最大适合性的字符串,那么可以先将'?'的下标存进vector数组里,然后用map记录下确定的值;要使两个字符串最匹配,直接遍历第二个字符串如果其中有和第一个字符串相同的字符,map数组减一下,如果没有相同的,为使匹配度最大直接将'?'改成当前字符就行了。

实现代码:

#include<bits/stdc++.h>
using namespace std;
map<char,int>mp;
vector<int>v;
int main()
{
ios::sync_with_stdio(false);
cin.tie();
string s1,s2;
int i;
cin>>s1;
cin>>s2;
for(i=;i<s1.size();i++){
if(s1[i]=='?')
v.push_back(i);
else
mp[s1[i]]++;
}
while(!v.empty()){
for(i=;i<s2.size();i++){
if(mp[s2[i]])
mp[s2[i]]--;
else{
s1[v.back()] = s2[i];
//cout<<s2[i]<<endl;
v.pop_back();
if(v.empty())
break;
}
}
}
cout<<s1<<endl;
return ;
}

ps: D还在等判题,突然被室友拉去打了把lol,打完感觉自己忘了什么,然后没多想直接写题解。。贴代码。。欣赏了一下,打开cf发现re了,发现应该是忘了加个break操作访问越界了,加完过了那组数据然后疯狂wa一组大的数据过不去,心态爆炸,找了一个小时的错误,最后发现把vector数组的数据定义错了,明明是int型,偏偏打成了char型,就这样还过了6个样例,是真的骚,不过最骚的还是自己脑子抽了题写错了还写解题思路写的贼起劲,我果然是个脑残。。。。

Educational Codeforces Round 25 A,B,C,D的更多相关文章

  1. Educational Codeforces Round 25 E. Minimal Labels&&hdu1258

    这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...

  2. Educational Codeforces Round 25 Five-In-a-Row(DFS)

    题目网址:http://codeforces.com/contest/825/problem/B 题目:   Alice and Bob play 5-in-a-row game. They have ...

  3. Educational Codeforces Round 25 C. Multi-judge Solving

    题目链接:http://codeforces.com/contest/825/problem/C C. Multi-judge Solving time limit per test 1 second ...

  4. Educational Codeforces Round 25 B. Five-In-a-Row

    题目链接:http://codeforces.com/contest/825/problem/B B. Five-In-a-Row time limit per test 1 second memor ...

  5. Educational Codeforces Round 25

    A 题意:给你一个01的字符串,0是个分界点,0把这个字符串分成(0的个数+1)个部分,分别求出这几部分1的个数.例如110011101 输出2031,100输出100,1001输出101 代码: # ...

  6. Educational Codeforces Round 25 E. Minimal Labels 拓扑排序+逆向建图

    E. Minimal Labels time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  7. Educational Codeforces Round 25 D - Suitable Replacement(贪心)

    题目大意:给你字符串s,和t,字符串s中的'?'可以用字符串t中的字符代替,要求使得最后得到的字符串s(可以将s中的字符位置两两交换,任意位置任意次数)中含有的子串t最多. 解题思路: 因为知道s中的 ...

  8. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  9. Educational Codeforces Round 60 (Rated for Div. 2) 题解

    Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...

随机推荐

  1. proxy config (firefox config)

    sudo apt-get install shadowsocks sudo apt-get install polipo 编辑polipo config: sudo vim /etc/polipo/c ...

  2. Luogu4423 BJWC2011 最小三角形 平面最近点对

    传送门 题意:给出$N$个点,求其中周长最小的三角形(共线的也计算在内).$N \leq 2 \times 10^5$ 这道题唤起了我对平面最近点对的依稀记忆 考虑平面最近点对的分治,将分界线两边的求 ...

  3. C#创建自己的扩展方法

    C#可以创建自己的扩展方法Extension Method: 参考这篇<判断是否为空然后赋值>http://www.cnblogs.com/insus/p/8004097.html 里,前 ...

  4. Ionic Android项目Splash设置

    ionic项目中,在splashscreen消失后会出现零点几秒的白屏,再出现app页面. 1. 安装Cordova splash screen插件 ionic plugin add org.apac ...

  5. React + js-xlsx构建Excel文件上传预览功能

    首先要准备react开发环境以及js-xlsx插件 1. 此处省略安装react安装步骤 2.下载js-xlsx插件 yarn add xlsx 或者 npm install xlsx 在项目中引入 ...

  6. 虚拟机console基础环境配置——系统镜像站点配置

    1. 概述2. 部署HTTP服务器2.1 YUM安装httpd2.2 配置httpd2.3 启动httpdf2.4 测试httpd3. 部署FTP服务器3.1 YUM安装vsftpd3.2 配置vsf ...

  7. Linux下IP SAN共享存储操作记录

    一.简单介绍SAN,即存储区域网络(storage area network and SAN protocols),它是一种高速网络实现计算机与存储系统之间的数据传输.常见的分类是FC-SAN和IP- ...

  8. curator 分布式锁InterProcessMutex

    写这篇文章的目的主要是为了记录下自己在zookeeper 锁上踩过的坑,以及踩坑之后自己的一点认识; 从zk分布式锁原理说起,原理很简单,大家也应该都知道,简单的说就是zookeeper实现分布式锁是 ...

  9. ACM找bug方案

    测试数据和一些常见的数据都通过了然而还是wrong,可以试试下面的一些解决方案: 1.数据爆掉 ①  可以改变数据类型,以容纳 ②  修改当前算法,比如a*a/b可以改写成a/b*a 2 特殊情况,例 ...

  10. Linux内核分析作业第五周

    系统调用的三个层次(下) 一.给MenuOS增加time和time-asm命令 1.克隆并自动编译 MenuOS rm menu -rf 强制删除原menu文件 git clone https://g ...