Codeforces Round #258 (Div. 2) D】的更多相关文章

Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意:  Akshat and Malvika两人玩一个游戏,横竖n,m根木棒排成#型,每次取走一个交点,交点相关的横竖两条木棒要去掉,Akshat先手,给出n,m问谁赢. 分析:  水题,非常明显无论拿掉哪个点剩下的都是(n-1,m-1),最后状态是(0,x)或(x,0),也就是拿了min(n,m)-…
A. Game With Sticks (451A) 水题一道,事实上无论你选取哪一个交叉点,结果都是行数列数都减一,那如今就是谁先减到行.列有一个为0,那么谁就赢了.因为Akshat先选,因此假设行列中最小的一个为奇数,那么Akshat赢,否则Malvika赢. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace…
题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把下降段的起始位置和结束位置记录下来然后进行推断,在进行推断时,有几种特殊情况:(s表示起始位置,e表示结束位置) 1.当e==n&&s!=1时,满足a[n]>a[s-1]输出yes: 2当s==1&&==n时,满足a[1]<a[e+1] 输出yes: 3当s==1&…
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hen…
D. Count Good Substrings 题目连接: http://codeforces.com/contest/451/problem/D Description We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after…
C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. You are an avid football fan, but…
B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers. Unfortunately, the size of a is to…
A. Game With Sticks 题目连接: http://codeforces.com/contest/451/problem/A Description After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks. A…
题目链接: http://codeforces.com/problemset/problem/451/E E. Devu and Flowers time limit per test4 secondsmemory limit per test256 megabytes 问题描述 Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flow…
题目链接:http://codeforces.com/problemset/problem/451/D D. Count Good Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We call a string good, if after merging all the consecutive equ…
题目链接:http://codeforces.com/contest/451/problem/B ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma…
A - Game With Sticks 题目的意思: n个水平条,m个竖直条,组成网格,每次删除交点所在的行和列,两个人轮流删除,直到最后没有交点为止,最后不能再删除的人将输掉 解题思路: 每次删除交点所在的行和列,则剩下n-1行和m-1列,直到行或列被删完为止,最多删除的次数为min(n,m),删除min(n,m)后剩余的都是行或者列(注意行与行,列与列之间不可能有交点).只需要判断min(n,m)的奇偶性. #include <iostream> #include <vector&…
题目链接 A. Game With Sticks time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard output After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a g…
解题报告 http://blog.csdn.net/juncoder/article/details/38102391 对于给定的数组,取对数组中的一段进行翻转,问翻转后是否是递增有序的. 思路: 仅仅要找到最初递减的区域,记录区域内最大和最小的值,和区间位置. 然后把最大值与区间的下一个元素对照,最小值与区间上一个元素对照. 这样还不够,可能会出现两个或两个以上的递减区间,这样的情况直接pass,由于仅仅能翻转一次. #include <iostream> #include <cstd…
解题报告 http://blog.csdn.net/juncoder/article/details/38102391 题意: n场比赛当中k场是没看过的,对于这k场比赛,a,b,c三队赢的场次的关系是a队与b队的绝对值差d1,b队和c队绝对值差d2,求能否使三支球队的赢的场次同样. 思路: |B-A|=d1 |C-B|=d2 A+B+C=k 这样就有4种情况,各自是: B>A&&C<B B>A&&C>B B<A&&C<B…
题意:找出一段逆序! 预存a[]数组到b[]数组.将b排序,然后前后找不同找到区间[l,r],然后推断[l,r]是否逆序就能够了!.当然还得特判本身就是顺序的!! ! AC代码例如以下: #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; int a[100005],b[100005]; int main() { int…
http://blog.csdn.net/rowanhaoa/article/details/38116713 A:Game With Sticks 水题.. . 每次操作,都会拿走一个横行,一个竖行. 所以一共会操作min(横行,竖行)次. #include<stdio.h> #include<iostream> #include<stdlib.h> #include<string.h> #include<algorithm> #include…
就枚举四种情况,哪种能行就是yes了.很简单,关键是写法,我写的又丑又长...看了zhanyl的写法顿时心生敬佩.写的干净利落,简直美如画...这是功力的体现! 以下是zhanyl的写法,转载在此以供学习: #include <vector> #include <list> #include <queue> #include <map> #include <set> #include <deque> #include <stac…
解题报告 http://blog.csdn.net/juncoder/article/details/38102263 n和m跟木棍相交,问一人取一交点(必须是交点.且取完后去掉交点的两根木棍),最后谁赢 思路: 取最大正方形,以对角线上的交点个数推断输赢. #include <iostream> #include <cstdio> using namespace std; int main() { int m,n; while(cin>>n>>m) { i…
D. Count Good Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. F…
B. Sort the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distin…
题意:n<20个箱子,每个里面有fi朵颜色相同的花,不同箱子里的花颜色不同,要求取出s朵花,问方案数 题解:假设不考虑箱子的数量限制,隔板法可得方案数是c(s+n-1,n-1),当某个箱子里的数量超过fi时,方案数是c(s-f[i]-1+n-1,n-1),容斥原理求,状压枚举哪几个箱子超过了f[i],答案就是超过0个-超过1个+超过2个... 由于c(n,m)的m很小,直接暴力求解 //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pr…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…