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 ...
随机推荐
- Python之路Day18
今天主要内容:Django Form.Django Admin.Django进阶 Django Admin 自带的验证: Django Admin的定制 Django Admin 自定义actions ...
- Python之路:迭代器和yield生成器
一.迭代器 对于Python 列表的 for 循环,他的内部原理:查看下一个元素是否存在,如果存在,则取出,如果不存在,则报异常 StopIteration.(python内部对异常已处理) 使用迭代 ...
- 这些屌炸天的创业者为何对投资人说NO
曾有人说,世上的创业者只分为两种,一种是找到投资的,一种是没有找到的. 但其实还有第三种,就是那些拒绝了投资人的创业者. 他们摒弃了投资人抛来的橄榄枝,并非不差钱,不接受投资的原因大体出于两个方面,一 ...
- qstring.h赏析
https://github.com/qtproject/qtbase/blob/dev/src/corelib/tools/qstring.h C:\Qt\Qt5.3.2_min\5.3\mingw ...
- XPath与多线程爬虫
XPath是一门在xml中查询信息的语言安装使用XPath 1.安装lxml库 window:pip install lxmllinux:sudo pip install lxml国内安装缓慢,建议到 ...
- 最短路Dijkstra和Flyod
Problem Description 在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt.但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要 ...
- H264格式具体说明
一 H.264句法1.1元素分层结构H.264编码器输出的Bit流中,每一个Bit都隶属于某个句法元素.句法元素被组织成有层次的结构,分别描写叙述各个 一 H.264句法 1.1元素分层结构 H.26 ...
- z-index要同级比较,absolute包含块外有overflow-hidden
z-index只能在position属性值为relative或absolute或fixed的元素上有效. z-index只决定同一父元素中的同级子元素的堆叠顺序. position:absolute ...
- BZOJ 1597: [Usaco2008 Mar]土地购买( dp + 斜率优化 )
既然每块都要买, 那么一块土地被另一块包含就可以不考虑. 先按长排序, 去掉不考虑的土地, 剩下的土地长x递增, 宽y递减 dp(v) = min{ dp(p)+xv*yp+1 } 假设dp(v)由i ...
- applicationContext.xml详解
http://blog.csdn.net/heng_ji/article/details/7022171