Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:24:38
Original
1101 people have browsed it

Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 : Akshat and Malvika两人玩一个游戏,横竖n,m根木棒排成#型,每次取走一个交点,交点相关的横竖两条木棒要去掉,Akshat先手,给出n,m问谁赢

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)-1次,判断奇偶即可。

代码

/*
*  Author:      illuz <iilluzen>
*  File:        A.cpp
*  Create Date: 2014-07-24 23:32:17
*  Descripton:   
*/

#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 0;
int a, b;

int main() {
	scanf("%d%d", &a, &b);
	if (min(a, b) % 2) {
		puts("Akshat");
	} else {
		puts("Malvika");
	}
	return 0;
}
</algorithm></cstdio></iilluzen>
Copy after login



B - Sort the Array

题意: 
给一个序列,求是否能够通过翻转中间一段数使得整个序列递增,并给翻转区间。

分析: 
数为10^5个,所以直接排序,然后找出区间验证即可。

代码

/*
*  Author:      illuz <iilluzen>
*  File:        B.cpp
*  Create Date: 2014-07-24 23:49:35
*  Descripton:   
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 1e5 + 10;

int n, beg, end, flag;
int a[N], b[N];
bool cont;

int main() {
	scanf("%d", &n);
	for (int i = 0; i = 0 && a[end] == b[end])
		end--;
	if (beg == n) {
		printf("yes\n");
		printf("1 1\n");
		return 0;
	}
	flag = true;
	for (int i = 0; i <br>
<br>

<hr>

<h2>
<span>C - Predict Outcome of the Game</span>
</h2>
<p>
<span>题意</span>: <br>
三支球队要进行n场足球比赛,已经进行了k场,已知一二两队胜局相差d1,二三两队胜局相差d2,问接下去有没可能出现三队胜局都一样,也就是平局的情况。</p>
<p>
<span>分析</span>: <br>
我们只知道是相差d1,d2,而不知道是那边比较多,所以有四种情况,判断四种情况就行了:</p>
<ol>
<li>判断已比赛场数的合法性: 判断已经进行的比赛场数s是否已经超过k了,如果没有超过,判断(k-s)是否能被3整除</li>
<li>判断剩余场数: 判断剩余场数能否把三队胜局填平,如果可以,看扣掉填平后的剩余场数是否能被3整除。</li>
</ol>
<p>
<span>代码</span>:</p>

<pre class="brush:php;toolbar:false">/*
*  Author:      illuz <iilluzen>
*  File:        C.cpp
*  Create Date: 2014-07-25 00:34:20
*  Descripton:   
*/

#include <iostream>
using namespace std;
typedef long long ll;

ll t, k, n, d1, d2, md;

bool jg(ll a, ll b, ll c) {
	ll s = a + b + c;
	if (k > t;
	while (t--) {
		cin >> n >> k >> d1 >> d2;
		md = max(d1, d2);
		if (jg(0, d1, d1 + d2) ||
			jg(d1 + d2, d2, 0) ||
			jg(d1, 0, d2) ||
			jg(md - d1, md, md - d2))
			cout <br>
<br>

<hr>

<h2>
<span>D - Count Good Substrings</span>
</h2>
<p>
<span>题意</span>: <br>
由a和b构成的字符串,如果压缩后变成回文串就是Good字符串。问一个字符串有几个长度为偶数和奇数的Good字串。</p>
<p>
<span>分析</span>: <br>
可以发现,不管怎么样,压缩后的字符串是<code>...ababab...</code>这种格式的,所以首尾字符相同,那就是Good字符串了。 <br>
我们还要证明下任意good字串的首尾字符串都是一样的,这不难。 <br>
奇偶问题的话,可以发现任意两个奇数位置上的a及中间的字符组成的字符串都是奇数长度的,同理偶数位置和b。奇数位置上的a和偶数位置上的a的字符串是偶数长度的。</p>
<p>
<span>代码</span>:</p>

<pre class="brush:php;toolbar:false">/*
*  Author:      illuz <iilluzen>
*  File:        D.cpp
*  Create Date: 2014-07-25 10:49:46
*  Descripton:   
*/

#include <iostream>
#include <string>
#define f(a) (a*(a-1)/2)
using namespace std;

string s;
long long r[2][2];

int main() {
	cin >> s;
	for (int i = 0; s[i]; i++)
		r[i&1][s[i]-'a']++;
	cout <br>

<hr>
<p>
总结:Orz帆神AK,E题涉及逆元,回头补上~</p>


</string></iostream></iilluzen>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template