浙江省赛 ZOJ - 4033】的更多相关文章

题意: 第一行给出T代表有几个测试样例, 第二行给出n代表有几个人, 第三行给出一个由0和1组成的字符串,0代表女生,1代表男生. 并且第i个人有i个宝石. 现在要把这些人分为四组,G1 G2 两组是女生组,G3 G4两组是男生组. 分配后要满足  (G1+G3)的宝石 ==(G2+G4)的宝石 然后输出这些人被分配到哪一组的字符串. 如果有多个结果随便哪一个都行,如果没有结果输出-1. 思路: 首先把所有宝石的总和判断一下,看看是偶数还是奇数,如果是奇数肯定分不均,直接输出-1. 然后把宝石总…
CONTINUE...? ZOJ - 4033 题解:先计算一下总数sum是否是偶数,如果不是则不能分出来,如果是则从后面开始分,先把人分到1.3组,分完sum / 2这些人,如果恰好能够分成零,那么剩下前面的都分到2.4组就可以了.如果不能,那么就把当前剩下的它需要的x能够凑成sum/2,将x这个地方的人分到1.3组. #include <cstdio> #include <cstring> #include <algorithm> #include <queu…
每年省赛必有的一道模拟题,描述都是非常的长,题目都是蛮好写的... sigh... 比赛的时候没有写出这道题目 :( 题意:首先输入4个数,n,q,p,c代表有n个队伍,q个服务器,每支队伍的初始分数p, 还有c次操作对于每次操作,首先输入一个k,代表k次攻击每次攻击有三个数,a,b,c, 代表a通过c服务器成功的攻击了b对于每次成功的攻击,b会失去n-1分, 这n-1分会平分给通过同一服务器攻击b的几支队伍然后是q行,每行n个数, 分别代表1~n是否成功维护了,1为成功,0为不成功不成功的队伍…
也是一道比赛时候没有写出来的题目,队友想到了解法不过最后匆匆忙忙没有 A 掉 What a pity... 题意:定义Beauty数是一个序列里所有不相同的数的和,求一个序列所有字序列的Beauty和 1 <= N <= 100000 解题思路:由于数据比较大,常规方法求字序列和肯定是行不通的,我们不妨这样想:因为要区别于不同的数 ,可以看成序列里的数是一个一个加进去的,每次加入一个数,统计前面序列里第一次出现新加入的这个数的位置,表达的不好, 举个例子: 1 2 3 定义dp(当前元素前面(…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3781 Time Limit: 2 Seconds      Memory Limit: 65536 KB Leo has a grid with N rows and M columns. All cells are painted with either black or white initially. Two cells A and B are calle…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3780 Time Limit: 2 Seconds      Memory Limit: 65536 KB Leo has a grid with N × N cells. He wants to paint each cell with a specific color (either black or white). Leo has a magical bru…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds      Memory Limit: 65536 KB The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order…
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3965 题目: iven two depth-first-search (DFS) sequences of a binary tree, can you find a binary tree which satisfies both of the DFS sequences? Recall that a binary tree is a tree in which…
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3962 题目: A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix…
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3961 题目: ACM (ACMers' Chatting Messenger) is a famous instant messaging software developed by Marjar Technology Company. To attract more users, Edward, the boss of Marjar Company, has re…