Codeforces Round #208 (Div. 2)
水题:直接模拟;
#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 ;
}
水题:按照顺序找就行了
#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 ;
}
水题:直接模拟,三个容器每个放一个大的,其他小的都放在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 ;
}
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)的更多相关文章
- Codeforces Round #208 (Div. 2) 358D Dima and Hares
题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过 ...
- Codeforces Round #208 (Div. 2) A.Dima and Continuous Line
#include <iostream> #include <algorithm> #include <vector> using namespace std; in ...
- Codeforces Round #208 (Div. 2) B Dima and Text Messages
#include <iostream> #include <algorithm> #include <string> using namespace std; in ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
随机推荐
- 关于Git和SVN的对比
1.git的提交是一个DAG有向无欢图.可以看到哥哥分支之间的合并关系.SVN的提交是一条直线. 2.git的提交版本号不是一个简单递增的数字,而是一个长达40位的十六进制数字(哈希值) 但是可以适用 ...
- 【Objective-C】2.自定义构造方法和description方法
1.Student.h 1 #import <Foundation/Foundation.h> 2 3 @interface Student : NSObject { 4 int _age ...
- (转)MySQL数据表中带LIKE的字符匹配查询
MySQL数据表中带LIKE的字符匹配查询 2014年07月15日09:56 百科369 MySQL数据表中带LIKE的字符匹配查询 LIKE关键字可以匹配字符串是否相等. 如果字段的值与指定的 ...
- 无责任比较thrift vs protocol buffers
http://blog.csdn.net/socoolfj/article/details/3855007 最新版本的Hadoop代码中已经默认了Protocol buffer作为RPC的默认实现,原 ...
- HashMap 与HashTable的区别
我们先看2个类的定义 public class Hashtable extends Dictionary implements Map, Cloneable, java.io.Serializable ...
- Microsoft SQL Server 获得本地帮助方法
微软的自带的帮助文档不管是对于开发人员还是DBA都是相当的重要.一般在有网络的状况下可以直接访问 http://msdn.microsoft.com/query/dev10.query?appId=D ...
- 【重叠I/O之系列三】I/O完成端口
一 串行模式和并行模式 一般一个服务应用程序采用以下两个架构模型之一: 串行模式 一个线程等待一个客户发出的请求,当请求到达的时候,线程会被换醒来处理客户的请求. 并发模式.一个线程等待一个客户 ...
- New Lantern Version Available Upgrade Lantern for improved blocking resistance!
New Lantern Version Available Upgrade Lantern for improved blocking resistance! The new version: is ...
- C++例题练习(2)
环境:Dev-C++( Version:5.6.1) 1.循环输入一个1-1000的整数,判断是否为素数(输入1时程序结束) 素数:只能被1和自身整除. 实现代码: #include <iost ...
- 使用C++11安全的在线程中控制UI
本篇文章由:http://www.sollyu.com/using-the-c11-secure-online-process-control-ui/ 说明 首先这里使用的是 Visual Studi ...