A - Dima and Continuous Line

水题:直接模拟;

 #include<cstdio>
#define maxn 1005
using namespace std;
int x[maxn],y[maxn];
int main()
{
int n,a,b,last;
scanf("%d",&n);
bool flag=;
for(int i=;i<n;i++)
{
scanf("%d",&b);
a=last;
last=b;
if(i==)continue;
if(a>b)
{
a=a^b;
b=a^b;
a=a^b;
}
if(flag)
for(int j=;j<i;j++)
{
if((a>x[j]&&a<y[j]&&b>y[j])||(x[j]>a&&b>x[j]&&y[j]>b))
flag=;
}
x[i]=a;
y[i]=b;
}
if(flag==)puts("yes");
else puts("no");
return ;
}

B - Dima and Text Messages

水题:按照顺序找就行了

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#define maxn 100005
using namespace std;
string s,t,c;
int main()
{
int n;
scanf("%d",&n);
s="<3";
for(int i=;i<n;i++)
{
cin>>c;
s+=c;
s+="<3";
}
cin>>t;
int j=;
int l=s.size();
int m=t.size();
for(int i=;i<m;i++)
{
if(s[j]==t[i])
{
j++;
if(j==l)break;
}
}
if(j==l)puts("yes");
else puts("no");
return ;
}

C - Dima and Containers

水题:直接模拟,三个容器每个放一个大的,其他小的都放在deck的另一边;

 #include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std; struct node
{
int id;
int num;
bool operator<(const node &t)const
{
return num<t.num;
}
}no[maxn]; int ans[maxn]; char s[][]={"pushStack","pushQueue","pushFront","pushBack","","popStack","popStack popQueue","popStack popQueue popFront"};
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d",&no[i].num);
no[i].id=i;
}
int j=;
for(int i=;i<n;i++)
{
if(no[i].num==&&i!=j)
{
int cnt=;
sort(no+j,no+i);
// for(int k=j;k<=i-1;k++)
// printf("%d<\n",no[k].num);
ans[no[i-].id]=;
cnt++;
if(i->=j){ans[no[i-].id]=;cnt++;}
if(i->=j){ans[no[i-].id]=;cnt++;}
if(i->=j)
{
for(int k=j;k<=i-;k++)
ans[no[k].id]=;
}
if(cnt==)ans[i]=;
if(cnt==)ans[i]=;
if(cnt==)ans[i]=;
j=i+;
}
else if(no[i].num==&&i==j){ans[i]=;j++;}
}
for(int i=;i<n;i++)
{
if(ans[i]<)puts(s[ans[i]]);
else printf("%d %s\n",ans[i]-,s[ans[i]]);
}
return ;
}

D - Dima and Hares

dp:

这个题挺不错的;

before[i]代表第i个兔子比它前面的那个先喂;

after[i]代表第i个兔子比它前面那个后喂;

然后扫一遍就行,注意边界条件

 #include<cstdio>
#include<algorithm>
#define maxn 3005
using namespace std; int map[][maxn];
int before[maxn],after[maxn]; int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&map[][i]);
for(int i=;i<=n;i++)
scanf("%d",&map[][i]);
for(int i=;i<=n;i++)
scanf("%d",&map[][i]);
before[]=;
after[]=-;
for(int i=;i<=n+;i++)
{
before[i]=max(before[i-]+map[][i-],after[i-]+map[][i-]);
after[i]=max(before[i-]+map[][i-],after[i-]+map[][i-]);
}
printf("%d\n",after[n+]);
return ;
}

Codeforces Round #208 (Div. 2)的更多相关文章

  1. Codeforces Round #208 (Div. 2) 358D Dima and Hares

    题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过 ...

  2. Codeforces Round #208 (Div. 2) A.Dima and Continuous Line

    #include <iostream> #include <algorithm> #include <vector> using namespace std; in ...

  3. Codeforces Round #208 (Div. 2) B Dima and Text Messages

    #include <iostream> #include <algorithm> #include <string> using namespace std; in ...

  4. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

随机推荐

  1. ADS的使用

    ADS是一款强大的软件,应用程序不能直接操作硬件,而ADS程序是无操作系统支持的,可以直接操作硬件,下面来介绍一下ADS的基本使用方法. 编辑本段基本简介: ADS(ARM Developer Sui ...

  2. Divide and conquer method

    分治法是最广泛使用的算法设计方法之一,其基本思想:把大问题分解成一些较小的问题,然后由小问题的解方便地构造出大问题的解. 分治法说穿了就是把问题放小,如果被分的问题还是比较大,那么久继续分下去.为了能 ...

  3. void指针、NULL指针和未初始化指针

    一个指针可以被声明为void类型,比如void *x.一个指针可以被赋值为NULL.一个指针变量声明之后但没有被赋值,叫做未初始化指针. 1 2 3 4 5 6 7 8 9 10 11 12 13 1 ...

  4. centos find

    首先你要确定你的软件是什么方式安装?如果不确定,你可知道你的软件名字,用find查找一下在哪个目录find / -name softname

  5. Android, JSONLIB , java.lang.NoClassDefFoundError: Failed resolution of: Lnet/sf/json/JSONArray; 原因

    出现这个错误的原因是因为引用的lib库的V4包与程序的V4包不兼容,替换成一致的包就OK了

  6. 【html】【21】高级篇--搜索框

    下载: http://www.xwcms.net/js/bddm/25368.html 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

  7. js事件冒泡和事件委托

    js事件冒泡 js所谓的事件冒泡就是子级元素的某个事件被触发,它的上级元素的该事件也被递归执行 html: <ul class="clearfix" data-type=&q ...

  8. FreeMarker-Built-ins for numbers

    http://freemarker.org/docs/ref_builtins_number.html#topic.extendedJavaDecimalFormat Page Contents ab ...

  9. 用python下载辞典

    用python下载词源词典Etymoline Online Etymology Dictionary是最好的 English 词源词典,现在来说没有之一.但是,一直在PC上查单词有时不是很方便,遂就想 ...

  10. HeadFirst设计模式-前言总结

    1 鸭子抽象类 class Duck { quack(); swim(); virtual display()=0 }; 现在如果让鸭子能够飞 class Duck { quack(); swim() ...