Codeforces Round #258 (Div. 2) 小结
A. Game With Sticks (451A)
水题一道,事实上无论你选取哪一个交叉点,结果都是行数列数都减一,那如今就是谁先减到行、列有一个为0,那么谁就赢了。因为Akshat先选,因此假设行列中最小的一个为奇数,那么Akshat赢,否则Malvika赢。
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int main()
{
int a, b;
while(~scanf("%d%d", &a, &b))
{
int minn = a>b?b:a;
if(minn%2==0)
printf("Malvika\n");
else
printf("Akshat\n");
}
return 0;
}
B. 451B - Sort the Array(451B)
考察是否能通过一次翻转,将数组变为升序。事实上就是考虑第一个下降的位置,和之后第一个上升的位置,推断边界值大小,细心的话非常easy发现。只是这道题坑点好多,尽管Pretest Pass了,可是,最后WA了,由于在output里面有一个条件没有考虑,就是(start
must not be greater than end) 。导致少写一个推断条件,好坑啊。
代码:
By dzk_acmer, contest: Codeforces Round #258 (Div. 2), problem: (B) Sort the Array, Accepted, #
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int main()
{
int n, a[100010];
while(~scanf("%d", &n))
{
for(int i = 1; i <= n; i++)
scanf("%d", &a[i]);
if(n == 1)
{
printf("yes\n1 1\n");
continue;
}
if(n == 2)
{
printf("yes\n");
if(a[1] < a[2])
printf("1 1\n");
else
printf("1 2\n");
continue;
}
int st = 1, ed = n, up = 0, down = 0;
for(int i = 2; i < n; i++)
{
if(a[i] > a[i-1] && a[i] > a[i+1])
{
up++;
st = i;
}
if(a[i] < a[i-1] && a[i] < a[i+1])
{
down++;
ed = i;
}
}
a[0] = -100;
a[n+1] = 1e9+2;
if(up >= 2 || down >= 2 || st >= ed || a[st] > a[ed+1] || a[ed] < a[st-1])
{
printf("no\n");
continue;
}
printf("yes\n");
if(a[st] > a[ed])
printf("%d %d\n", st, ed);
else
printf("1 1\n");
}
return 0;
}
Codeforces Round #258 (Div. 2) 小结的更多相关文章
- Codeforces Round #258 (Div. 2)[ABCD]
Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...
- Codeforces Round #258 (Div. 2) B. Sort the Array
题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...
- Codeforces Round #258 (Div. 2) E. Devu and Flowers 容斥
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to deco ...
- Codeforces Round #258 (Div. 2) D. Count Good Substrings 水题
D. Count Good Substrings 题目连接: http://codeforces.com/contest/451/problem/D Description We call a str ...
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题
C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...
- Codeforces Round #258 (Div. 2) . Sort the Array 贪心
B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, ...
- Codeforces Round #258 (Div. 2) A. Game With Sticks 水题
A. Game With Sticks 题目连接: http://codeforces.com/contest/451/problem/A Description After winning gold ...
- Codeforces Round #258 (Div. 2) 容斥+Lucas
题目链接: http://codeforces.com/problemset/problem/451/E E. Devu and Flowers time limit per test4 second ...
- Codeforces Round #258 (Div. 2) D. Count Good Substrings —— 组合数学
题目链接:http://codeforces.com/problemset/problem/451/D D. Count Good Substrings time limit per test 2 s ...
随机推荐
- ThinkPHP第三天(公共函数Common加载,dump定义,模板文件,定义替换__PUBLIC__)
1.公共函数定义 自动加载:在项目的common文件夹中定义,公共函数文件命名规则为common.php,只有命名成common.php才能被自动载入. 动态加载:可以修改配置项‘LOAD_EXT_F ...
- Nginx 之三:nginx服务器模块、web请求处理机制及事件驱动模型、进程功能和进程间通信
一:Nginx的模块化结构设计: 1.核心模块:指的是nginx服务器运行当中必不可少的模块,这些模块提供了最基本最核心的服务,比如权限控制.进程管理.错误日志.事件驱动.正则表达式解析等,nginx ...
- IOS 隐藏键盘。
在View的UITextField中经常需要输入完文字后隐藏软键盘,要实现着一点要让View的Controller实现UITextFieldDelegate代理,然后编写相应的代码. #import ...
- Spring MVC 入门基础
欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入 原文链接:http://java.chinaitlab.com/advance/899129.html 基本上是一个精简版的 ...
- filezilla Can't open data connection.
(000003)2016/7/4 9:31:42 - (not logged in) (10.61.41.57)> Connected, sending welcome message... ( ...
- 枚举子集的3种方式 -- C++描述
要求: 给定一个集合,枚举所有可能的子集.此处的集合是不包含重复元素的. Method0: 增量构造法 思路:每次选取一个元素至集合中,为了避免枚举重复的集合,此处要采用定序技巧 -- 除了第一个元素 ...
- 历时一年,我的著作《第一行代码——Android》已出版!
前言 事实上我当初决定開始写博客的想法挺简单的,认为自己搞技术这么多年了,总应该要留下点什么.既然没能写出什么出色的应用,那至少也要留下点文字分享给大家,以指引在我后面的开发人员们,毕竟我也从前辈们的 ...
- material design是什么?(待以后学习)
1.它的各种示例:http://blog.csdn.net/cike110120/article/details/46572071 2.它的讲解:http://www.androidchina.net ...
- ThreadLocal 和 InheritableThreadLocal (引用)
ThreadLocal:http://www.cnblogs.com/moonandstar08/p/4912673.html InheritableThreadLocal: http://www. ...
- ubuntu安装ulipad
以下内容部分我是从其他地方找的,并且做了适当的修改,亲身测试可以安装成功 在安装ulipad之前,先安装一个超级好用的Python的交互式Shell--iPython.iPython功能很强大, ...