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. 新建linux组、用户命令

    之前在安装oracle的时候,出现了一个问题:安装Oracle,新建组.用户的时候的一个错误.看这篇博客前,先看这个链接,学习要从解决出现的问题出手. 建立用户组和用户 下面总结一下Linux建立组和 ...

  2. ThinkPHP 3.1.2 控制器的模块和操作

    本节课大纲: 一.空模块和空操作 1.空操作 function _empty($name){ $this->show("$name 不存在 <a href='__APP__/In ...

  3. java学习之IO字符流

    package com.io; import java.io.*; /** * 文件字符流的读取 * @author ganhang * */ public class FileReaderDemo ...

  4. Android之drawable state各个属性具体解释

    我们在定义一个drawable的时候能够通过xml定义的drawable对象.它使得一个图片能在不同的状态下显示不同的图案,比方一个Button,它有pressed.focused,或者其他状态,通过 ...

  5. Codeforces 360C Levko and Strings dp

    题目链接:点击打开链接 题意: 给定长度为n的字符串s,常数k 显然s的子串一共同拥有 n(n-1)/2 个 要求找到一个长度为n的字符串t,使得t相应位置的k个子串字典序>s #include ...

  6. 【Eclipse Plugin】SonarQube 启动报错

    由于近期,信息安全部在搞代码优化工作.所以,配合上边的工作需求,使用sonar对代码进行优化检测.在Eclipse上装Sonar很简单,只要在Eclipse Marketplace上面搜索“Sonar ...

  7. 字符相等(E - 暴力求解、DFS)

    判断字符相等 Description Today on a lecture about strings Gerald learned a new definition of string equiva ...

  8. Cocos2dx项目移植Android平台

    链接地址:http://blog.csdn.net/iuncle/article/details/24772183 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.Classes目录下存放. ...

  9. BZOJ 1042: [HAOI2008]硬币购物( 背包dp + 容斥原理 )

    先按完全背包做一次dp, dp(x)表示x元的东西有多少种方案, 然后再容斥一下. ---------------------------------------------------------- ...

  10. Python-zip压缩-解压

    #打包成zip文件 import zipfile f = zipfile.ZipFile('archive.zip','w',zipfile.ZIP_DEFLATED) f.write('file_t ...