As everyone knows, bears love fish. But Mike is a strange bear; He hates fish! The even more strange thing about him is he has an infinite number of blue and red fish. He has marked n distinct points in the plane. i-th point is point (xi, yi). He wan…
Mike and Fish 我们可以把这个模型转换一下就变成有两类点,一类是X轴, 一类是Y轴, 每个点相当于对应的点之间建一条边, 如果这条边变红两点同时+1, 变蓝两点同时-1. 我们能发现这个图其实是个二分图, 我们可以随便取一个点开始走路, 红蓝间隔开来,那么中间的点就权值不变, 对于最末尾的点虽然权值有改变,但是只会改变一次, 就这样一直走路直到所有的边都遍历完. #include<bits/stdc++.h> #define LL long long #define fi firs…
D. Mike and Fish http://codeforces.com/contest/547/problem/D 题意: 给定平面上n个点,将这些点染成红或者蓝色,要求每行.每列红色点与蓝色点数量的差的绝对值<=1.输出方案(保证有解). 分析: 参考popoqqq的博客 将每行每列分别看做一个点,给定的每个点(x,y)拆成x->y的边,那么连边后的图是一个二分图. 这样我们可以将边染色,使得与每个点相连的两种颜色差<=1. 于是对于所有的欧拉回路,我们可以直接交替染色. 但是会…
codeforces 547E Mike and Friends 题意 题解 代码 #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define rep(i, a, b) for(int i=(a); i<(b); i++) #define per(i, a, b) for(int i=(b)…
C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful…
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! As…
B. Mike and Shortcuts time limit per test: 3 seconds memory limit per test: 256 megabytes input: standard input output: standard output Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some si…
C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is…
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m g…
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, …
题目链接:http://codeforces.com/gym/100971/problem/K K. Palindromization time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Mihahim has a string s. He wants to delete exactly one character from it so that th…
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
C. They Are Everywhere time limit per test: 2 seconds memory limit per test:256 megabytes input: standard input output: standard output Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from le…
题目链接:http://codeforces.com/problemset/problem/798/C 题意:给你n个数,a1,a2,....an.要使得gcd(a1,a2,....an)>1,可以执行一次操作使ai,ai+1变为ai - ai + 1, ai + ai + 1.求出使得gcd(a1,a2,....an)>1所需要的最小操作数. 解题思路:首先,要知道如果能够实现gcd(a1,a2,....an)>1,那么a1~an肯定都是偶数(0也是偶数),所以我们的目的就是用最少的操…
C - Sorting Railway Cars Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u CodeForces 606C Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are…
原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of choco…