题目链接:http://codeforces.com/contest/734/problem/C C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he i…
C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next…
C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a…
A. Anton and Danik time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known…
E. Anton and Tree 题目连接: http://codeforces.com/contest/734/problem/E Description Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph. There are n vertices in the tree, each of them is painted bla…
D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to…
B. Anton and Digits 题目连接: http://codeforces.com/contest/734/problem/B Description Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6. Anton's favorite integers are 32 and 256. He decide…
A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was the winner - Anton or Danik. None of th…
题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmemory limit per test256 megabytes 问题描述 Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that pla…
题目链接:http://codeforces.com/contest/734/problem/E E. Anton and Tree time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Anton is growing a tree in his garden. In case you forgot, the tree is a…
题目链接:http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton likes to play chess. Also, he likes to do programming. That is why…
E. Anton and Tree time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph. There are n v…
题意: 给你n对 b[i], c[i], 让你求a[i],不存在输出-1 b[i] = (a[i] and a[1]) + (a[i] and a[2]) + (a[i] and a[3]) +...+ (a[i] and a[n]); c[i] = (a[i] or a[1]) + (a[i] or a[2]) + (a[i] or a[3]) +...+ (a[i] or a[n]); and 和 or 是按位与 或 思路: (a and b) + (a or b) = (a + b) 证明…
题意: 给一颗树 每个节点有黑白2色 可以使一个色块同事变色,问最少的变色次数. 思路: 先缩点 把一样颜色的相邻点 缩成一个 然后新的树 刚好每一层是一个颜色. 最后的答案就是树的直径/2 不过我用的树上的dp,强行求了以每个点为根时树的深度 答案就是最小的深度-1 具体见代码: + ; int n; int color[maxn]; int pa[maxn]; vector<int> G[maxn], G2[maxn]; void init() { scanf("%d"…
传送门 题意: 这道题说的是在一颗有两种颜色的树上,每操作一个节点,可以改变这个节点颜色和相邻同色节点的颜色.问最少操作次数,使得树上颜色相同. 思路: 先缩点,把相同的颜色的相邻节点缩在一起.再求出树的最长直径S(边的个数),答案就是(S + 1)/ 2: 因为对于一条链,我们可以从中间向两边交换改变. #include <bits/stdc++.h> #define pb push_back using namespace std; ; vector<int>mp[MAXN],…
C. Anton and Fairy Tale 题目连接: http://codeforces.com/contest/785/problem/C Description Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale: "Once upon a time, there liv…
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再看自己的代码发现有清晰的思维是多重要 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include…
A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lucky_ji: 水题,模拟统计A和D的数目比较大小输出结果即可 Tags: Implementation B.Anton and Digits Problems: 给定k2个2,k3个3,k5个5及k6个6,可以组成若干个32或256,求所有方案中Sigma的最大值 Analysis: lucky_ji: 同…
前言 初入acm的新手,打算在cf混.这几天没有比赛,就做了个最新的Virtual participation.虽然说div2比较简单,但还是被虐得体无完肤...Orz.两个小时,共6道题.最后只AC了AB两道,花了20分钟,剩下的100分钟也不知道哪去了(逃 A.B两道水题没什么说的.那我们从C题开始吧 C. Anton and Making Potions 题意 制作n瓶药水,初始时每制作一瓶花费x秒,有两类法术,第一类(包含m个法术)使制作每瓶药的时间由x变为a[i] (a[i] < x)…
B. Anton and Lines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/problem/B Description The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforc…
D. Anton and School - 2 题目连接: http://codeforces.com/contest/785/problem/D Description As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn differ…
B. Anton and Lines   The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = ki·x + bi. It was necess…
E. Anton and Ira Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/E Description Anton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid game…
B. Anton and Classes 题目连接: http://codeforces.com/contest/785/problem/B Description Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes. Anton has n variants when he wil…
A - Anton and Polyhedrons 题目连接: http://codeforces.com/contest/785/problem/A Description Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular face…
题目地址 本次CF是在今天早上深夜进行,上午有课就没有直接参加.今天早上上课坐到后排参加了virtual participation.这次CF前面的题目都非常的水,不到10分钟就轻松过了前两题,比较郁闷的是之后一直卡在C,开始是脑残的没有用二分TLE,后来又是因为一个常数打错而一直WA--于是模拟赛就只过了2道题(太弱了orz).时间到了后很快发现了脑残错误,终于A了C题.下午上完课回到宿舍看D题才发现D题水的不行,很快就A了.不过E和F就比较超出我现在知识范围了,暂时就先放下.第一次参加vir…
B. Anton and currency you all know time limit per test 0.5 seconds memory limit per test 256 megabytes input standard input output standard output Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that…
http://codeforces.com/blog/entry/50996 官方题解讲得很明白,在这里我复述一下. 枚举每个左括号,考虑计算一定包含其的简单括号序列的个数,只考虑其及其左侧的左括号,以及其右侧的右括号.最后答案就是其之和. 可以将其提取出来这样((((((())),红色为当前左括号.设有x个左,y个右 要注意,这个答案为C(x+y-1,x),来证明. 我们只需证明,这个答案与长度为x+y-1的,包含x个1的零一序列的种类数相等即可. 随便写一个这样的零一序列,长度为x+y,但当…
E. Anton and Permutation time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a…
A ~~ B ~~ C 对于第二种方法,我们可以任取一个换c[i]个potions,花费d[i]:或者是不取,我的做法就是枚举这些情况,得到剩余的s,再尽量优的获取小的a[i]: 枚举+二分 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define ls i<<1 #define rs ls | 1 #def…