C. The Game Of Parity
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.

The prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.

Lord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.

Input

The first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·105) — the initial number of cities in Westeros and the number of cities at which the game ends.

The second line contains n space-separated positive integers ai (1 ≤ ai ≤ 106), which represent the population of each city in Westeros.

Output

Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.

Examples
input
3 1
1 2 1
output
Stannis
input
3 1
2 2 1
output
Daenerys
input
6 3
5 20 12 7 14 101
output
Stannis
Note

In the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.

In the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.

题目大意:

n个城市,每人轮流屠掉一个城市,最后剩下k个城市,如果剩下的k个城市的人数和是奇数,那么先手赢,否则后手赢。

思路:

如果后手能够有机会屠掉所有奇数城,那么先手必败。

如果有奇数城剩余,继续考虑如果要屠的城为奇数座,那么先手可以最后利用偶数城,调整当前奇数城的数量,必胜。

但是如果后手能够将偶数城全部干掉,那么最后就变成看剩下的k是奇数还是偶数了。

如果要杀偶数个城,那么后手可以做最后调整,如果先手杀不光偶数城,那么后手必胜,如果先手能杀光偶数城,

那么结果就看剩下的k是奇数还是偶数了。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
int n,k,a[];
int main()
{
scanf("%d%d",&n,&k);
int i,cnt=;
for (i=;i<=n;i++)
{
int x;
scanf("%d",&x);
if (x&) cnt++;
}
int num2=(n-k)>>;
int num1=(n-k+)>>;
bool fg=true;
if (cnt<=num2)
fg=false;
if (k%==&&n-cnt<=num2)
fg=false;
if ((n-k)%==)
{
if ((num1>=n-cnt&&k%)==false)
fg=false;
}
if (n==k)
fg=(cnt&)?true:false;
puts(fg?"Stannis":"Daenerys");
return ;
}

Codeforces 549C(博弈)的更多相关文章

  1. Codeforces 549C The Game Of Parity【博弈】

    C语言纠错大赛的一道题,正好拿来补博弈~~ 给的代码写的略奇葩..不过还是直接在上面改了.. 题目链接: http://codeforces.com/problemset/problem/549/C ...

  2. Codeforces 549C The Game Of Parity(博弈)

    The Game Of Parity Solution: 这个题只需要分类讨论就可以解决. 先分别统计奇数和偶数的个数. 然后判断谁走最后一步,如果走最后一步时候同时有偶数和奇数,那么走最后一步的赢. ...

  3. Codeforces 549C. The Game Of Parity[博弈论]

    C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Codeforces 354B 博弈, DP,记忆化搜索

    题意:现在有一个字符矩阵,从左上角出发,每个人交替选择一个字符.如果最后字符a数目大于字符b,那么第一个人获胜,否则b获胜,否则平均.现在双方都不放水,问最后结果是什么? 思路:这题需要注意,选择的字 ...

  5. Ticket Game CodeForces - 1215D 博弈题

    题目描述 Monocarp and Bicarp live in Berland, where every bus ticket consists of n digits (n is an even ...

  6. ACM 博弈(难)题练习 (第一弹)

    第二弹: 套路&&经验总结: 1. N堆***的游戏,一般可以打表找SG函数的规律.比如CodeForces 603C 2.看起来是单轮的游戏,实际上可能拆分成一些独立的子游戏.比如C ...

  7. Codeforces 455B A Lot of Games(字典树+博弈)

    题目连接: Codeforces 455B A Lot of Games 题目大意:给定n.表示字符串集合. 给定k,表示进行了k次游戏,然后是n个字符串.每局開始.字符串为空串,然后两人轮流在末尾追 ...

  8. CodeForces 1099F - Cookies - [DFS+博弈+线段树]

    题目链接:https://codeforces.com/problemset/problem/1099/F Mitya and Vasya are playing an interesting gam ...

  9. codeforces 812E Sagheer and Apple Tree(思维、nim博弈)

    codeforces 812E Sagheer and Apple Tree 题意 一棵带点权有根树,保证所有叶子节点到根的距离同奇偶. 每次可以选择一个点,把它的点权删除x,它的某个儿子的点权增加x ...

随机推荐

  1. Javascript中setTimeout()以及clearTimeout( )的使用

    setTimeout setTimeout( ) 是属于 window 的 method, 这是用来设定一个时间,时间到了, 就会执行一个指定的 方法.练习一:等候三秒才执行的 alert( )set ...

  2. 在Servlet中使用@Autowire的方法

    在你调用的Servlet中添加如下代码: public void init(ServletConfig config) { try { super.init(config); SpringBeanAu ...

  3. mybatis获取存储过程返回结果

    获取存储过程返回结果 代码: // Map<String,Object> map = new HashMap<String,Object>(); map.put("i ...

  4. Python3简明教程(五)—— 流程控制之循环

    有些时候我们需要多次执行相同的任务,我们使用一个计数器来检查代码需要执行的次数.这个技术被称为循环. while循环 while语句的语法如下: while condition: statement1 ...

  5. diff - 找出两个文件的不同点

    总览 diff [选项] 源文件 目标文件 描述 在最简单的情况是, diff 比较两个文件的内容 (源文件 和 目标文件). 文件名可以是 - 由标准输入设备读入的文本. 作为特别的情况是, dif ...

  6. linux ABORT的应用详解

    NAME ABORT - 退出当前事务 SYNOPSIS ABORT [ WORK | TRANSACTION ] DESCRIPTION 描述 ABORT 回卷当前事务并且废弃所有当前事务中做的更新 ...

  7. C-基础:关于预编译以及宏

    这是没有引入任何头文件时,如果使用"NULL",编译器会报错:没有定义NULL.此时可用下面代码定义. #undef NULL //#undef 是在后面取消以前定义的宏定义#if ...

  8. 小程序02 wxml和wxss

    微信小程序的排版就跟wxml和wxss有关,它们两者相当于HTML和CSS,其中wxml指定了界面的框架结构,而wxss指定了界面的框架及元素的显示样式. 一.wxml 界面结构wxmL比较容易理解, ...

  9. dpdk快速编译使用

    QuickStart 环境 dpdk: dpdk-17.11 运行前配置 配置系统HugePages #mkdir /mnt/huge_1GB/ #vim /etc/fstab nodev /mnt/ ...

  10. Vue之过滤器的使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...