因为再不全力投入华为软件精英挑战赛就来不及了!
而且直播时讲过题了,所以只能粗略写一个题解,希望大家包涵>.<
基本可以参考代码,可以画图模拟加思考脑补其原理与过程23333~~
会后续有人写题解的啦!感谢参加经费、人员都不足的第二届CCPC女生赛! 希望明年我也有机会参赛!
06是claris的防AK题,虽然我试图几次想要说服换掉这题。想补的可以找claris或者等几天2333
PS:预测全对
![第二届CCPC女生赛 粗略题解(要做重现的不要看哦)_第1张图片](http://img.e-com-net.com/image/info8/957e8f6070e34872b7771cacc20e06f1.jpg)
PS2:我真的不会说话和撩妹啊哈哈哈哈 T_____________________________________T
【2017CCPC女生赛 A】【水题 模拟】Automatic Judge
Automatic Judge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Welcome to HDU to take part in the second CCPC girls’ competition!
A new automatic judge system is used for this competition. During the five-hour contest time, you can submit your code to the system, then the judge will reply you. Here is a list of the judge's replies and their meaning:
1.
Accepted(AC) : Yes, your program is correct. You did a good job!
2.
PresentationError(PE) : Your program's output format is not exactly the same as required by the problem, although the output is correct. This usually means the existence of omitted or extra blank characters (white spaces, tab characters and/or new line characters) between any two non-blank characters, and/or blank lines (a line consisting of only blank characters) between any two non-blank lines. Trailing blank characters at the end of each line and trailing blank lines at the of output are not considered format errors. Check the output for spaces, blank lines, etc. against the problem's output specification.
3.
WrongAnswer(WA) : Correct solution not reached for the inputs. The inputs and outputs that we use to test the programs are not public (it is recomendable to get accustomed to a true contest dynamic :-)
4.
RuntimeError(RE) : Your program failed during the execution and you will receive the hints for the reasons.
5.
TimeLimitExceeded(TLE) : Your program tried to run during too much time.
6.
MemoryLimitExceeded(MLE) : Your program tried to use more memory than the judge default settings.
7.
OutputLimitExceeded(OLE) : Your program tried to write too much information. This usually occurs if it goes into a infinite loop.
8.
CompilationError(CE) : The compiler fails to compile your program. Warning messages are not considered errors. Click on the judge's reply to see the warning and error messages produced by the compiler.
For each submission, if it is the first time that the judge returns ``AC'' on this problem, then it means you have passed this problem, and the current time will be added to the penalty of your team. In addition, every time you pass a problem, each unsuccessful try for that problem before is counted as 20 minutes penalty, it should also be added to the penalty of your team.
Now given the number of problems in the contest and the submission records of a team. Please write a program to calculate the number of problems the team passed and their penalty.
Input
The first line of the input contains an integer
T(1≤T≤20) , denoting the number of test cases.
In each test case, there are two integers
n(1≤n≤13) and
m(1≤m≤100) in the first line, denoting the number of problems and the number of submissions of a team. Problems are labeled by 1001, 1002, ...,
1000+n .
In the following
m lines, each line contains an integer
x(1001≤x≤1000+n) and two strings
t(00:00≤t≤05:00) and
s , denoting the team submits problem
x at time
t , and the result is
s .
t is in the format of HH:MM, while
s is in the set \{AC, PE, WA, RE, TLE, MLE, OLE\}. The team is so cautious that they never submit a CE code. It is guaranteed that all the
t in the input is in ascending order and every
t is unique.
Output
For each test case, print a single line containing two integers
A and
B , denoting the number of problems the team passed and the penalty.
Sample Input
1
3 5
1002 00:02 AC
1003 00:05 WA
1003 00:06 WA
1003 00:07 AC
1002 04:59 AC
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 B】【DP】Building Shops
Building Shops
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
HDU’s
n classrooms are on a line ,which can be considered as a number line. Each classroom has a coordinate. Now Little Q wants to build several candy shops in these
n classrooms.
The total cost consists of two parts. Building a candy shop at classroom
i would have some cost
ci . For every classroom
P without any candy shop, then the distance between
P and the rightmost classroom with a candy shop on
P 's left side would be included in the cost too. Obviously, if there is a classroom without any candy shop, there must be a candy shop on its left side.
Now Little Q wants to know how to build the candy shops with the minimal cost. Please write a program to help him.
Input
The input contains several test cases, no more than 10 test cases.
In each test case, the first line contains an integer
n(1≤n≤3000) , denoting the number of the classrooms.
In the following
n lines, each line contains two integers
xi,ci(−109≤xi,ci≤109) , denoting the coordinate of the
i -th classroom and the cost of building a candy shop in it.
There are no two classrooms having same coordinate.
Output
For each test case, print a single line containing an integer, denoting the minimal cost.
Sample Input
3
1 2
2 3
3 4
4
1 7
3 1
5 10
6 1
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 C】【暴力】Coprime Sequence
Coprime Sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Do you know what is called ``Coprime Sequence''? That is a sequence consists of
n positive integers, and the GCD (Greatest Common Divisor) of them is equal to 1.
``Coprime Sequence'' is easy to find because of its restriction. But we can try to maximize the GCD of these integers by removing exactly one integer. Now given a sequence, please maximize the GCD of its elements.
Input
The first line of the input contains an integer
T(1≤T≤10) , denoting the number of test cases.
In each test case, there is an integer
n(3≤n≤100000) in the first line, denoting the number of integers in the sequence.
Then the following line consists of
n integers
a1,a2,...,an(1≤ai≤109) , denoting the elements in the sequence.
Output
For each test case, print a single line containing a single integer, denoting the maximum GCD.
Sample Input
3
3
1 1 1
5
2 2 2 3 2
4
1 2 4 8
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 D】【最短路+计数】Deleting Edges
Deleting Edges
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Little Q is crazy about graph theory, and now he creates a game about graphs and trees.
There is a bi-directional graph with
n nodes, labeled from 0 to
n−1 . Every edge has its length, which is a positive integer ranged from 1 to 9.
Now, Little Q wants to delete some edges (or delete nothing) in the graph to get a new graph, which satisfies the following requirements:
(1) The new graph is a tree with
n−1 edges.
(2) For every vertice
v(0<v<n) , the distance between 0 and
v on the tree is equal to the length of shortest path from 0 to
v in the original graph.
Little Q wonders the number of ways to delete edges to get such a satisfied graph. If there exists an edge between two nodes
i and
j , while in another graph there isn't such edge, then we regard the two graphs different.
Since the answer may be very large, please print the answer modulo
109+7 .
Input
The input contains several test cases, no more than 10 test cases.
In each test case, the first line contains an integer
n(1≤n≤50) , denoting the number of nodes in the graph.
In the following
n lines, every line contains a string with
n characters. These strings describes the adjacency matrix of the graph. Suppose the
j -th number of the
i -th line is
c(0≤c≤9) , if
c is a positive integer, there is an edge between
i and
j with length of
c , if
c=0 , then there isn't any edge between
i and
j .
The input data ensure that the
i -th number of the
i -th line is always 0, and the
j -th number of the
i -th line is always equal to the
i -th number of the
j -th line.
Output
For each test case, print a single line containing a single integer, denoting the answer modulo
109+7 .
Sample Input
2
01
10
4
0123
1012
2101
3210
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 E】【分块打表 原题】Easy Summation
Easy Summation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
You are encountered with a traditional problem concerning the sums of powers.
Given two integers
n and
k . Let
f(i)=ik , please evaluate the sum
f(1)+f(2)+...+f(n) . The problem is simple as it looks, apart from the value of
n in this question is quite large.
Can you figure the answer out? Since the answer may be too large, please output the answer modulo
109+7 .
Input
The first line of the input contains an integer
T(1≤T≤20) , denoting the number of test cases.
Each of the following
T lines contains two integers
n(1≤n≤10000) and
k(0≤k≤5) .
Output
For each test case, print a single line containing an integer modulo
109+7 .
Sample Input
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 F】【Bitset 不会做 有空补】Forgiveness 需要补★
Forgiveness
Time Limit: 14000/7000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Little Q is now checking whether string
A matches
B . Two strings are considered matched if they have the same length, and there are no position
i that
Ai is different from
Bi .
However, Little Q is a kind man, he forgives every person hurt him. What's more, he even forgives strings! He gives the string 3 opportunities, if there are no more than 3 positions
i that
Ai is different from
Bi , then Little Q will also consider the two strings matched.
For a string
S ,
S[l,r] means the substring combined by
Sl,Sl+1,...,Sr . And the function
occ(A,B) returns the number of substrings in string
B which matches
A .
Little Q now has a long numeric 1-based string
S , and his job is to deal with
m operations:
1. +
l
r
k , for every positions from
l to
r , change
Si to
(Si+k)mod10 .
2. ?
l
r
T , report
occ(T,S[l,r]) .
After lots of work, Little Q is very tired now, please write a program to help him deal with these operations.
Input
The first line of the input contains an integer
T(1≤T≤15) , denoting the number of test cases.
In each test case, there are two integers
n(1≤n≤50000) and
m(1≤m≤50000) in the first line, denoting the length of string
S and the number of operations.
The second line of the input contains a numeric string
S with
n integers, each number
Si is in the range of 0 to 9.
In the following
m lines, each line describes an operation.
If it is a modification, then it is in the format of ''+
l
r
k '', where
1≤l≤r≤n and
1≤k≤9 .
If it is a query, then it is in the format of ''?
l
r
T '', where
1≤l≤r≤n and
T is a numeric string composed of integers from 0 to 9.
It is guaranteed that
∑|T|≤100000 in each test case, and there are no more than
4 test cases satisfying
min(n,m)>1000 .
Output
For each query, print a single line with an integer, denoting the answer.
Sample Input
1
5 5
01234
? 2 5 1234
? 2 5 1777
? 2 5 9999
+ 1 5 5
? 1 5 56789
Sample Output
【2017CCPC女生赛 G】【判定】Graph Theory 要不不连前缀边 要不连所有前缀边 判判断是否可以n个数配成二分之n对
Graph Theory
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Little Q loves playing with different kinds of graphs very much. One day he thought about an interesting category of graphs called ``Cool Graph'', which are generated in the following way:
Let the set of vertices be {1, 2, 3, ...,
n }. You have to consider every vertice from left to right (i.e. from vertice 2 to
n ). At vertice
i , you must make one of the following two decisions:
(1) Add edges between this vertex and all the previous vertices (i.e. from vertex 1 to
i−1 ).
(2) Not add any edge between this vertex and any of the previous vertices.
In the mathematical discipline of graph theory, a matching in a graph is a set of edges without common vertices. A perfect matching is a matching that each vertice is covered by an edge in the set.
Now Little Q is interested in checking whether a ''Cool Graph'' has perfect matching. Please write a program to help him.
Input
The first line of the input contains an integer
T(1≤T≤50) , denoting the number of test cases.
In each test case, there is an integer
n(2≤n≤100000) in the first line, denoting the number of vertices of the graph.
The following line contains
n−1 integers
a2,a3,...,an(1≤ai≤2) , denoting the decision on each vertice.
Output
For each test case, output a string in the first line. If the graph has perfect matching, output ''Yes'', otherwise output ''No''.
Sample Input
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 H】【矩阵快速幂】Happy Necklace 珍珠染色素数都满足
Happy Necklace
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Little Q wants to buy a necklace for his girlfriend. Necklaces are single strings composed of multiple red and blue beads.
Little Q desperately wants to impress his girlfriend, he knows that she will like the necklace only if for every prime length continuous subsequence in the necklace, the number of red beads is not less than the number of blue beads.
Now Little Q wants to buy a necklace with exactly
n beads. He wants to know the number of different necklaces that can make his girlfriend happy. Please write a program to help Little Q. Since the answer may be very large, please print the answer modulo
109+7 .
Note: The necklace is a single string,
{not a circle}.
Input
The first line of the input contains an integer
T(1≤T≤10000) , denoting the number of test cases.
For each test case, there is a single line containing an integer
n(2≤n≤1018) , denoting the number of beads on the necklace.
Output
For each test case, print a single line containing a single integer, denoting the answer modulo
109+7 .
Sample Input
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 I】【LCA 时间戳】Innumerable Ancestors
Innumerable Ancestors
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
There is a tree having
n nodes, labeled from 1 to
n . The root of the tree is always 1, and the depth of a node
p is the number of nodes on the shortest path between node
p and the root.
In computer science, the Lowest Common Ancestor (LCA) of two nodes
v and
w in a tree is the lowest (i.e. deepest) node that has both
v and
w as descendants, where we define each node to be a descendant of itself (so if
v has a direct connection from
w ,
w is the lowest common ancestor).
You have to answer
m queries. Each query gives two non-empty node sets
A and
B , there might be some nodes in both sets.
You should select one node
x from set
A , and one node
y from set
B ,
x and
y can be the same node. Your goal is to maximize the depth of the LCA of
x and
y .
Please write a program to answer these queries.
Input
The input contains several test cases, no more than 5 test cases.
In each test case, the first line contains two integers
n(1≤n≤100000) and
m(1≤m≤100000) , denoting the number of nodes and queries.
For the next
n−1 lines,each line contians two integers
a and
b , denoting a bi-directional edge between node
a and
b .
Then there are
2m lines, every two lines describes one query.
For each query, the first line describes the set A.
The first integer
k(1≤k≤n) denotes the number of nodes in set
A , and the next
k integers describing the nodes in set
A . There might be some nodes appear multiple times in the set.
The second line describes the set
B in the same format of set
A .
It is guaranteed that
∑k≤100000 in each test case.
Output
For every query, print a number denoting the answer, which means the maximum depth of the LCA.
Sample Input
7 3
1 2
1 3
3 4
3 5
4 6
4 7
1 6
1 7
2 6 7
1 7
2 5 4
2 3 2
Sample Output
#include
#include
#include
#include
#include
#include
#include
#include
【2017CCPC女生赛 J】【DP博弈】Judicious Strategy
Judicious Strategy
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Alice and Bob is now playing a game about strings.
There is a dictionary containing
n words (words might be same). Alice choose a lowercase English letter arbitrarily first, but this letter should appear in at least one of these
n words. Then Bob choose a lowercase English letter arbitrarily to add it before or after the letter Alice chose. So Bob gets a new string now. This new string should also be a substring (consecutive subsequence) of at least one strings in the dictionary. After that, it's Alice's turn. Alice should do the same thing, choosing a letter and add it before or after the current string, making a new string. At every moment, the string they made should always be a substring of at least one strings in the dictionary. The player who can't operate first lose the game and the other one win.
Besides, each player has a score. The score is calculated by the following rule:
If the string
S is now made, the current player will get
score(S) points. It means that Alice will score in the first round, then Bob, then Alice...
score(S)=⎡⎣⎛⎝∑i=1|S|value(Si)⎞⎠×maxi=1|S|value(Si)⎤⎦+occ(S)
where
1.
|S| means the length of
S .
2.
value(c) represents the value of letter
c . The score of letter ``a'' is 1, ``b'' is 2, ..., ``z'' is 26.
3.
occ(S) means the time that
S occurs as a substring in the dictionary, each word is counted just once.
Alice and Bob will play with best strategy. That is to say, they will consider to win first and then maximize their score, after that they will consider to minimize the score of others.
Please determine who will win the game, and report the final scores they will earn during the whole game.
Input
The input contains several test cases, no more than 10 test cases.
In each test case, the first line contains an integer
n(1≤n≤30) , denoting the number of words in the dictionary.
In the next
n lines, each line contains a non-empty string
wordi , denoting a word in the dictionary. The string is composed of lowercase English letters and its length will not exceed 30.
Output
For each test case, output a string in the first line. If Alice will win ,output ''Alice'', otherwise output ''Bob''.
Then print two integers
A and
B in second line, denoting the final score of Alice and Bob.
Sample Input
2
aba
abac
3
artem
nik
max
Sample Output
Bob
29 35
Alice
2403 1882
#include
#include
#include
#include
#include
#include
#include
#include