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) 小结的更多相关文章

  1. Codeforces Round #258 (Div. 2)[ABCD]

    Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...

  2. Codeforces Round #258 (Div. 2) B. Sort the Array

    题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #258 (Div. 2) . Sort the Array 贪心

    B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, ...

  7. Codeforces Round #258 (Div. 2) A. Game With Sticks 水题

    A. Game With Sticks 题目连接: http://codeforces.com/contest/451/problem/A Description After winning gold ...

  8. Codeforces Round #258 (Div. 2) 容斥+Lucas

    题目链接: http://codeforces.com/problemset/problem/451/E E. Devu and Flowers time limit per test4 second ...

  9. 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 ...

随机推荐

  1. Spring学习之杂七杂八

    源码解读Spring IOC原理 - http://www.cnblogs.com/ITtangtang/p/3978349.html 1. 使用Groovy配置Bean http://blog.cs ...

  2. vim插件管理之Vundle

    Vim是一个类似于Vi的著名的功能强大.高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性.正是由于其可定制的特性, 许许多多的Vim插件便诞生了.管理这些插件又成为我们最为头疼的问题,最近无 ...

  3. 无法更新 EntitySet“GuigeInfo”,因为它有一个 DefiningQuery,而 <ModificationFunctionMapping> 元素中没有支持当前操作的 <InsertFunction> 元素。

    1:实体中必须有主键 2:删除创建的模型重新创建

  4. Java学习之二分查找算法

    好久没写算法了.只记得递归方法..结果测试下爆栈了. 思路就是取范围的中间点,判断是不是要找的值,是就输出,不是就与范围的两个临界值比较大小,不断更新临界值直到找到为止,给定的集合一定是有序的. 自己 ...

  5. [python]通过urllib2设置代理访问网址

    #!/usr/bin/env pythonimport urllib2 # change followings before useuser = 'foo'passwd = 'bar'proxyser ...

  6. android Graphics(一):概述及基本几何图形绘制

    前言:我最近想抽空研究研究android的各种特效,android的特效真是其它平台无法比拟的,而且一个漂亮的UI交互,会给APP增色不少,而学习特效之前,有关graphics绘图的基础知识是必不可少 ...

  7. vim插件配置(一)

    vim代码自动显示提示代码插件:AutoComplPop:  代码(普通变量函数) c/c++代码(类的 . , ->, :: 操作符)的自动补全插件: OmniCppComplete

  8. 转化为用欧几里得算法判断互质的问题D - Wolf and Rabbit

    Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must h ...

  9. ASP.NET MVC 5 学习教程:Edit方法和Edit视图详解

    原文 ASP.NET MVC 5 学习教程:Edit方法和Edit视图详解 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 ...

  10. Sitemesh3的使用及配置

    1 . Sitemesh 3 简介 Sitemesh 是一个网页布局和修饰的框架,基于 Servlet 中的 Filter,类似于 ASP.NET 中的‘母版页’技术.参考:百度百科,相关类似技术:A ...