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 ...
随机推荐
- 210 - Concurrency Simulator(WF1991, deque, 模拟)
题目有点长,理解题花了不少时间 粘下别人的翻译~ 你的任务是模拟n个程序(按输入顺序编号为1~n)的并行执行.每个程序包含不超过25条语句,格式一共有5种: var=constant(赋值): pri ...
- Javascript实现图片无缝滚动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- EL表达式简单应用
<%@page import="java.util.HashMap"%> <%@page import="java.util.List"%&g ...
- spring beans的写入工具——spring-beans-writer
spring-beans-writer是我曾经为动态生成spring beans配置文件做的一个写入工具,托管地址: https://github.com/bluejoe2008/spring-bea ...
- c#中字符串显示上标和下标解决办法
由于工作的需求,需要在word中插入带入带有上标和下标的字符串,比如这样的一个字符串:SO₄²⁻(mg/L).在网上搜了好久,终是摸索出点思路. 解决办法:使用转义字符加Unicode的HexEnti ...
- UITabBar - 深度解剖
for (UIView *tabbarbutton in self.subviews) { // NSLog(@"%@",tabbarbutton); ...
- Objective-C 学习笔记(Day 2)
------------------------------------------- 如何根据题目准确完整清晰的声明一个类并实现给定的行为 /* //下面这个程序教大家如何根据题目去声明一个类,并 ...
- 9月18日,SQL学习基础1
数据库管理和应用 Oltp是小型的管理,OLAP是大型的管理 开发的内容如触发器 数据库管理系统(Database Management System,简称为DBMS)是位于用户与操作系统之间的一层数 ...
- C语言 goto, return等跳转
C语言 goto, return等跳转 Please don't fall into the trap of believing that I am terribly dogmatical about ...
- KMP(匹配)
Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据, ...