J.The Keys Out of all science labs constructed by the GEMA mission on Mars, the DSL - Dangerous Species Lab is the most dangerous of them all. The laboratory is so dangerous that you have to go through N doors in succession to get to it. Each one of…
C.Sleep Buddies It is nighttime in the Earth Colony on Mars and everyone is getting ready to sleep. It is common to sleep in pairs, so that if anything were to happen during the night people could aid each other. To decide who is a suitable candidate…
F.Bandejao It is lunch time on Mars! Everyone has got that big smile on their faces, all eager to see what the GEMA restaurant is serving for dessert. Everything is pretty much like Earth, but nobody knows why, GEMA decided to invent new types of ute…
C. Bear and Colors 题目连接: http://www.codeforces.com/contest/673/problem/C Description Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n.…
B. Problems for Round 题目连接: http://www.codeforces.com/contest/673/problem/B Description There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficult…
C. Little Artem and Matrix 题目连接: http://www.codeforces.com/contest/669/problem/C Description Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new contro…
B. Problems for Round time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty,…
题目链接  2016 ACM-ICPC EC-Final Problem G 题意  给定一个无向图.每个点有一种颜色. 现在给定$q$个询问,每次询问$x$和$w$,求所有能通过边权值不超过$w$的边走到$x$的点的集合中,哪一种颜色的点出现的次数最多. 次数相同时输出编号最小的那个颜色.强制在线. 求哪种颜色可以用线段树合并搞定. 关键是这个强制在线. 当每次询问的时候,我们先要求出最小生成树在哪个时刻恰好把边权值不超过$w$的边都用并查集合并了. 在做最小生成树的时候每合并两个节点,另外开…
连接在这里,->点击<- A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and ther…
Codeforces 题目传送门 & 洛谷题目传送门 难度终于出来了--又独立切掉一道 *3200,凯信(所以我已经独立切掉三道 *3200 了?) 首先考虑我们已经知道了每个宝箱上有哪些锁,怎样求 Bob 的最大利益,这显然就是一个最大权闭合子图的模板,我们将箱子看作左部点,钥匙看作右部点,对于每个箱子 \(i\) 我们连一条 \(S\) 到该箱子表示的点,容量为 \(a_i\) 的边,对于每个钥匙 \(j\) 我们连一条该钥匙所表示的点到 \(T\),容量为 \(b_i\) 的边,最后对于每…
A - Little Artem and Presents (div2) 1 2 1 2这样加就可以了 #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 + 5; int main() { int n; scanf ("%d", &n); int ans = n / 3 * 2; if (n % 3) { ans++; } printf ("%d\n", ans);…
题目链接: http://codeforces.com/contest/673/problem/D 题意: 给四个不同点a,b,c,d,求是否能构造出两条哈密顿通路,一条a到b,一条c到d. 题解: 构造法,看例子: input: 5 6 5 2 4 1 output: 5 4 3 1 2 4 5 3 2 1 所以只要满足k>=n+1,就可以构造出来答案. #include<iostream> #include<cstring> #include<cstdio>…
题目链接: http://codeforces.com/contest/673/problem/C 题解: 枚举所有的区间,维护一下每种颜色出现的次数,记录一下出现最多且最小的就可以了. 暴力n*n. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> using namespace std; ; const int…
题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2.1,2位置交换,3,4位置交换,...,n-1,n位置交换 现在问执行了q次操作之后序列是什么,每次操作可以是两种操作的任意一种 题解: 我们把数列按位置的奇偶分为两堆,无论哪种操作,始终都还是这两堆,最多就是整堆的对换和一个堆内部的偏移. 所以我们只要记录第一个位置和第二个位置的数的变化(相当于每…
<题目链接> 题目大意: 有n个瓶子,各有水量和容量.现在要将这写瓶子里的水存入最少的瓶子里.问你最少需要的瓶子数?在保证瓶子数最少的情况下,要求转移的水量最少. 解题分析:首先,最少的瓶子数肯定可以通过贪心来简单求解.然后就是将所有瓶子的水量作为01背包的总体积,然后就是$dp[i][j]$表示前$i$个物品选了水量为$j$的最大容量.本题的这种逆向思维有点像那道小偷抢银行的01背包题.但是因为本题规定了需要选取的那些容量大的物品,所以略有不同.对这$n$个物品进行01背包,杯子的水量看成体…
D. Bear and Two Paths 题目连接: http://www.codeforces.com/contest/673/problem/D Description Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same p…
A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Each minute can be either interesting or…
C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Description Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Cons…
E. Little Artem and Time Machine 题目连接: http://www.codeforces.com/contest/669/problem/E Description Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply thi…
D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cuban dance that is danced by pairs of boys and girls forming a circle and dancing tog…
B. Little Artem and Grasshopper 题目连接: http://www.codeforces.com/contest/669/problem/B Description Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1 × n. Each ce…
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the prese…
J. Bottles time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottl…
J. Rising Sun time limit per test 1.0 s memory limit per test 1024 MB input standard input output standard output Joon has a midterm exam tomorrow, but he hasn't studied anything. So he decided to stay up all night to study. He promised himself that…
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n…
C. Little Artem and Matrix time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in t…
 Problem J Judging Moose 这个题是这里面最简单的一个题... 代码: 1 //J 2 #include <stdio.h> 3 #include <math.h> 4 #include <string.h> 5 #include <stdlib.h> 6 #include <iostream> 7 #include <sstream> 8 #include <algorithm> 9 #includ…
J Just A Minim 超级无敌大水题,但是被精度卡了一手,输出要精确到小数点后6位,我直接输出的... 代码: 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 #include<set> 7 #include<algorithm> 8 #include<map&g…
[题目链接]:http://codeforces.com/contest/801/problem/B [题意] 定义一个对两个字符串x,y的f(x,y)函数; 返回的是一个字符串; 这个返回的字符串的每一位i是x和y在相应位置上的字符的较小值; 告诉你x和f(x,y); 求y; [题解] 如果f(x,y)[i]==x[i]则y[i]='z'; 否则 如果f(x,y)[i]>x[i]则y[i]=x[i] 否则 无解 [Number Of WA] 0 [完整代码] #include <bits/s…
A.暴力枚举,注意游戏最长为90分钟 B.暴力,c[l]++,c[r]--,记录中间有多长的段是大小为n的,注意特判m=0的情况 C.暴力枚举,我居然一开始没想出来!我一直以为每次都要统计最大的,就要O(N^3).实际上只要判断最大的那个. D.构造,在除了a,b,c,d之外的点构造一条链,只需要n+1条边就可以了.n=4的时候特判.…