B. Balanced Diet 思路:把每一块选C个产生的价值记录下来,然后从小到大枚举C. #include<bits/stdc++.h> using namespace std; ; typedef long long ll; vector<int> G[maxn]; int l[maxn], a[maxn], b[maxn]; ll dp[maxn]; bool cmp(int a, int b) { return a > b; } int main() { std:…
题解: solution Code: A. Apple Business #include<cstdio> #include<algorithm> #include<vector> using namespace std; typedef long long ll; const int N=100010; int Case,len[N],n,m,i,mx,a[N],size[N],tmp[N];ll ans; vector<ll>v[N],f[N]; str…
题目大意:给定一棵 N 个点的树,边有边权,定义"线树"为一个图,其中图的顶点是原树中的边,原树中两条有公共端点的边对应在线图中存在一条边,边权为树中两条边的边权和,求线图的最小生成树的代价是多少. 题解: 对于树中的一个顶点来说,假设有 M 条边以该顶点为一个端点,那么这 M 条边对应到线图中的顶点必须要求能够构成一个联通块.另外,可以发现这个问题的解决和其他顶点无关,即:对于树上每个顶点来说,构成了一个子问题.因此,考虑一个贪心策略,即:每次用边权最小的那条边和其他所有边相连,这样…
ZOJ Problem Set - 3946 Highway Project Time Limit: 2 Seconds Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus…
The Lucky Week Time Limit: 2 Seconds Memory Limit: 65536 KB Edward, the headmaster of the Marjar University, is very busy every day and always forgets the date. There was one day Edward suddenly found that if Monday was the 1st, 11th or 21st day…
People Counting Time Limit: 2 Seconds Memory Limit: 65536 KB In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitress take a photo for them. Everyone w…
Defuse the Bomb Time Limit: 2 Seconds Memory Limit: 65536 KB The bomb is about to explode! Please defuse it as soon as possible! There is a display showing a number from 1 to 4 on the bomb. Besides this, there are 4 buttons under the display. Ea…
Heap Partition Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge A sequence S = {s1, s2, ..., sn} is called heapable if there exists a binary tree T with n nodes such that every node is labelled with exactly one element from the se…
Firdaws and Fatinah are living in a country with nn cities, numbered from 11 to nn.Each city has a risk of kidnapping or robbery. Firdaws's home locates in the city uu, and Fatinah's home locates in the city vv.Now you are asked to find the shortest…
Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 429 Accepted Submission(s): 244 Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial Collegiate Programming Contest - K Capture the Flag Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge In computer security, Capture…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial Collegiate Programming Contest - B Team Formation Time Limit: 3 Seconds Memory Limit: 131072 KB For an upcoming programming contest, Edward, the…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial Collegiate Programming Contest - D Beauty of Array Time Limit: 2 Seconds Memory Limit: 65536 KB Edward has an array A with N integers. He defines…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial Collegiate Programming Contest - J Convert QWERTY to Dvorak Time Limit: 2 Seconds Memory Limit: 65536 KB Edward, a poor copy typist, is a user o…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial Collegiate Programming Contest - H May Day Holiday Time Limit: 2 Seconds Memory Limit: 65536 KB As a university advocating self-learning and work…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504 The 12th Zhejiang Provincial Collegiate Programming Contest - L Demacia of the Ancients Time Limit: 2 Seconds Memory Limit: 65536 KB There is a popular multiplayer online ba…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial Collegiate Programming Contest - A Ace of Aces Time Limit: 2 Seconds Memory Limit: 65536 KB There is a mysterious organization called Time-Space…
Problem A Almost Palindrome Given a line of text, find the longest almost-palindrome substring. A string S is almost-palindrome if S begins and ends with a letter, and a(S) and b(S) have at most 2k positions with different characters Here a(S) is the…
Problem F Funny Car Racing There is a funny car racing in a city with n junctions and m directed roads. The funny part is: each road is open and closed periodically. Each road is associate with two integers (a, b), that means the road will be open fo…
Problem H High bridge, low bridge Q: There are one high bridge and one low bridge across the river. The river has flooded twice, why the high bridge is flooded twice but the low bridge is flooded only once? A: Because the lower bridge is so low that…
Problem I Interesting Calculator There is an interesting calculator. It has 3 rows of button. Row 1: button 0, 1, 2, 3, ..., 9. Pressing each button appends that digit to the end of the display. Row 2: button +0, +1, +2, +3, ..., +9. Pressing each bu…
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two. From the theorem, we know that a3 + b3 = c3 has no positive i…
Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student names. However, there are too many students, so I failed. It is a shame, so I don't want my students to know this. Whenever I need to call someone, I c…
Problem L Last Blood In many programming contests, special prizes are given to teams who solved a particular problem first. We call the first accepted solution "First Blood". It's an interesting idea to set prizes for "Last Blood". The…
Problem C Character Recognition? Write a program that recognizes characters. Don't worry, because you only need to recognize three digits: 1, 2 and 3. Here they are: .*. *** *** .*. ..* ..* .*. *** *** .*. *.. ..* .*. *** *** Input The input contains…
Game Rooms Time Limit: 4000/4000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Status Your company has just constructed a new skyscraper, but you just noticed a terrible problem: there is only space to put one game room on each…
E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard input output:standard output Syrian Collegiate Programming Contest (SCPC) is the qualified round for the Arab Collegiate Programming Contest. Each year S…
A. Airport Coffee 设$f_i$表示考虑前$i$个咖啡厅,且在$i$处买咖啡的最小时间,通过单调队列优化转移. 时间复杂度$O(n)$. #include<cstdio> const int N=500010; typedef long long ll; const double inf=1e20; ll L,A,B,T,R,lim0,lim1,a[N]; double f[N],val[N]; double dp0=inf; int id0; int pre[N]; int…