首页 > 其他分享 >Codeforces549C - The Game Of Parity

Codeforces549C - The Game Of Parity

时间:2023-06-12 18:03:48浏览次数:34  
标签:even Parity Codeforces549C puts Stannis else Game Daenerys odd


原题链接


C. The Game Of Parity



time limit per test



memory limit per test



input



output


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

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



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.

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


Output



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



1.首先若n == k则直接判断

2.若(n - k)为奇数,则最后一次操作的执行者是Stannis,此时要想Stannis赢,要么奇数和偶数都存在,要么奇数的个数为偶数个

3.若(n-k)为偶数,则最后一次操作的执行者是Daenerys,此时要想Stannis赢,那么只存在奇数,且奇数的个数为偶数个

#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#define MOD 1000000007
#define maxn 100005
using namespace std;
typedef long long ll;

int main(){
	
//	freopen("in.txt", "r", stdin);
	int n, k, odd = 0, even = 0, a;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%d", &a);
		if(a&1)
		 odd++;
		else
		 even++;
	}
	if(n == k){
		if(odd&1)
		 puts("Stannis");
		else
		 puts("Daenerys");
	}
	else{
		int d = n - k - 1;
		if(d % 2 == 0){
			d /= 2; 
			if(even > d && odd > d)
			    puts("Stannis");
			else if(d >= even && (odd - (2 * d - even)) % 2 == 0)
			     puts("Stannis");
			else
			    puts("Daenerys");
		}
		else{
		    d /= 2;
		    d++;
		    if(d >= even && (odd - (d * 2 - 1 - even)) % 2 == 0)
		     puts("Stannis");
		    else
		     puts("Daenerys");
		}
	}
	return 0;
}





标签:even,Parity,Codeforces549C,puts,Stannis,else,Game,Daenerys,odd
From: https://blog.51cto.com/u_16158872/6464580

相关文章

  • [ABC303G] Bags Game 解题分析
    1题目大意1.1题目翻译有两个人轮流取物品。总共有\(n\)个物品,第\(i\)个物品的价值为\(w_i\)。他们按照下面的其中一种方式取物品:取出这一排物品最前面的或者最后面的。这一步没有代价。设还剩下\(m\)个物品,那么重复取出\(\min(B,m)\)个物品,每次取出最前面的......
  • 【每日一题】Problem 327A - Flipping Game
    原题解决思路计算数字"1"的最大数目,可以转换成计算数组最大和,即求\(maxSum(oldArraySum-(1\rightarrow0)+(0\rightarrow1))\RightarrowoldArraySum+maxSum(flipSum)\)误区注意:题目要求必须执行一次,因此起始值不是0而是-1#include<bits/stdc++.h>intm......
  • 基于Python+tkinter+pygame的音乐播放器完整源码
    importosimporttkinterimporttkinter.filedialogimportrandomimporttimeimportthreadingimportpygamefolder=''defplay():#folder用来表示存放MP3音乐文件的文件夹globalfoldermusics=[folder+'\\'+musicfo......
  • [ABC166F] Three Variables Game
    ThreeVariablesGameの传送门Solution首先,我们每次操作只会修改两个数。所以考虑dfs枚举操作的顺序,但是这让时间复杂度变为\(O(2^n)\),不能接受。但是,我们可以判断当a<0||b<0||c<0时,就退出,这样可以减少绝大部分状态。边界条件:当枚玩\(n\)个后,输出用\(ans......
  • GameHub项目开发笔记
    技术栈搭建项目项目在HbuilderX中进行开发,新建时使用默认模板,选择Vue2版本,并且启用uniCloud(阿里云)项目代码托管到GitHub,.gitignore文件配置如下#/test/表示忽略根目录下的test目录及其所有内容。/uniCloud-aliyun//.hbuilderx//uni_modules//unpackage/学习参考:https:/......
  • [ABC201D] Game in Momotetsu World 题解
    GameinMomotetsuWorld题目大意在一个\(n\timesm\)的网格中,存在红色和蓝色两种格子,红色格子用-表示,蓝色格子用+表示。现在Takahashi和Aoki要在这个网格中进行游戏,游戏的规则如下:初始时,有一枚棋子摆放在左上角,即\((1,1)\)的位置。两名玩家的分数均为\(0\)。......
  • AtCoder Beginner Contest 258 G Grid Card Game
    洛谷传送门AtCoder传送门记\(b_i=\sum\limits_{j=1}^ma_{i,j},c_j=\sum\limits_{i=1}^na_{i,j}\)。首先考虑这样一个事情,就是对于\(b_i\le0\)的行有没有可能被选。如果选了它:如果没有选任何列,选这一行肯定不优;如果选了若干列,根据题目的要求,这若干列与这......
  • pygame-04加载人物图片与显示
    1-实例代码importmath,randomimportpygamefrompygameimportmixer#游戏初始化pygame.init()#窗口设置screen=pygame.display.set_mode((800,600))#背景设置background=pygame.image.load('background.png')#背景音乐,-1表示循环播放mixer.music.load(......
  • pygame-03游戏界面等环境配置
    1-示例代码importmath,randomimportpygamefrompygameimportmixer#游戏初始化pygame.init()#窗口设置screen=pygame.display.set_mode((800,600))#背景设置background=pygame.image.load('background.png')#背景音乐,-1表示循环播放mixer.music.load(......
  • Pygame制作答题类游戏的实现
    概述个人比较喜欢玩这些答题类的游戏,在这类的游戏中其实存在着一些冷知识在里面。练习pygame的过程中,在网络上搜索,几乎没有找到这类游戏的示例教程,就蒙生了制作一个答题游戏的念头,最开始的时候,这个游戏是使用键盘输入的方式来答题的,没有开始界面,没有结束界面,后来几经修改,改为全鼠标......