The problem is that I was in Sunday, the day before yesterday played a team game, the topic is not easy to find
Topic Link: http://codeforces.com/gym/100861 on Virtual judge can also submit Oh!
A ACM ICPC Rules:
The main topic: There are many colleges and universities to participate in the qualifying, and in the qualifying rankings, but for each school, in addition to the MSU has 4 places in other universities only two places (that is, only the top 2 of each university into the final (MSU four) && up to 10 teams into the final), The high school team couldn't get into the finals. Give the qualifying rankings, the output can go to the final list, (up to 10)
Problem analysis: This problem or to see the solution out, feel that they do too few problems, many problems can be done is to do the method of trouble, so after more to do the problem tamping, first if encounter "SCH" on continue, create a map<string, int> Record the number of occurrences of each string, and then create a vector<pair<string that string>> V stores into the MSU rankings.
#include <iostream>#include<vector>#include<string>#include<map>#include<algorithm>using namespaceStd;vector<pair<string,string>>V;map<string,int>MAP;intMain () {intN; while(Cin >>N) {intLim =0; for(inti =1; I <= N; i++ ) { stringA, B; CIN>> a >>b; if(A = ="SCH")Continue; Else { if(A = ="MSU") Lim =4; ElseLim =2; } if(Map[a] <Lim) {Map[a]++; V.push_back (Make_pair (A, b)); } } intans1 = min (Ten, (int) v.size ()); cout<< ans1 <<Endl; for(inti =0; i < ans1; i++) {cout<< V[i].first <<" "; cout<< V[i].second <<Endl; } } return 0;}View Code
G Genesis Project:
Topic: To a number of points, every two points will generate a new point, the position is the midpoint of the two-point line, the current point has a "child" after the current point will disappear, the occurrence of two points of the position coincides with the situation of the "number of breeding" is how much?
Title Analysis: First to know that the midpoint of any quadrilateral must be parallelogram, and the midpoint of the parallelogram diagonal line coincident, so that when the number of points greater than 4, the maximum breeding times is 2! If you think of this, it is too stupid to do the problem, too little! Then the answer is 1 is a point exactly at the midpoint of the two points position, (n >= 4), when only <= 3 points, no matter how can not coincide! (But there is a special case is three points, one point is the midpoint of the other two points, it should be output 1, but no special treatment has been given (may be data water))
And then again how to find two coincident, first build a pair< int, int > P SET container, to store the x, y coordinate of the point, then push P into SET, the last 22 enumeration, if Set.count (P) = = 1 break off After output 1, if n <= 3 is output 0, the rest is used in the above method, if the search results in the output 2~!
Attached code:
#include <cstdio>#include<Set>#include<algorithm>#include<cstring>using namespacestd;Set< pair<int,int> >S;pair<int,int> a[1004];intN;intMain () {scanf ("%d", &N); S.clear (); Memset (A,0,sizeof(a)); for(inti =1; I <= N; i++) {scanf ("%d%d", &a[i].first, &A[i].second); } if(N <=3) {printf ("0\n" ); return 0; } for(inti =1; I <= N; i++ ) { for(intj = i +1; J <= N; J + +) {pair<int,int>P; P= Make_pair (A[i].first + a[j].first, A[i].second +A[j].second); if(S.count (P)) {printf ("1\n" ); return 0; } s.insert (P); }} printf ("2\n" ); return 0;}View Code
L. Lucky Bonds:
The main idea: give the definition of lucky number, for the sum of the first n and the second n numbers equal, such as "1340" 1 + 3 = 4 + 0 This number is lucky numbers, obviously the number of digits is 2 * N. Enter an n to find the left and right intervals of the maximum consecutive non-lucky number interval of 2 * N.
Title Analysis: The problem is a structural problem, but first see the range of n is very small, 1 ~ 10, so in the thought can play the table will be the results, violence is simple, when n = 1, 2, 3 when the answer is 89, 98; 9899, 9998;
998999, 999998; So the result of the subsequent direct play out on the table, the code is very ugly.
Then is the construction method, it is obvious that the problem is a special judge, so I take 8, 9 as an example, to construct the answer, assuming that n = 3, the right end is 999998, the left end is the first lucky number from 999998 to the left number (some awkward, but think carefully Want to still be able to understand), after three bits and for 9 + 9 + 8, so the first three bits can only be 8 + 9 + 9, 9 + 8 + 9, 9 + 9 + 8, and because 9 9 8 combination is closest to 999998 (the first lucky number on the left) so constructs The method is that the end value of the left interval is nth + 1 bit 8 and the remainder is 9:
Attach the ugliest code in history .....
#include <iostream>#include<cstdio>#include<cstring>#include<string>using namespacestd;stringans[ -] = { " "," ", " the","98", "9899","9998", "998999","999998", "99989999","99999998", "9999899999","9999999998", "999998999999","999999999998", "99999989999999","99999999999998", "9999999899999999","9999999999999998", "999999998999999999","999999999999999998", "99999999989999999999","99999999999999999998"};intMain () {intN; while(Cin >>N) {cout<< ans[2*n] << Endl << ans[2*n+1] <<Endl; } return 0;}View Code
There are two questions, after a period of time to fill the whole!
ACM ICPC 2008–2009 neerc MSC A, B, C, G, L