1. [Programming Questions] Circus
Sohu staff Xiao Wang recently used vacation in the field travel, in a small town met a circus performance, after the wonderful performance found the Colonel is and everyone in front of the tent heated discussion, Xiao Wang inquired about the next learned that the circus is going to a new program "tallest Arhat Tower", that is, the circus dogpile performance. Considering the safety factor, it is required that the person standing on the shoulder of a person should be shorter and thinner than himself, or equal, in the dogpile process. The head wants the highest of the Arhat tower in this program, because of the large number of people, is a headache how to arrange personnel problems. Xiao Wang felt that the problem was simple, so he counted the height and weight of all the members involved in the highest performance of the Arhat tower and quickly found the highest-Lohanta sequence of people. Now that you've got a height and weight table, find the height of the highest Lohanta that can be stacked, and the circus members are numbered 1 to n in turn.
Input Description:
First a positive integer n, which represents the number of people. The next n lines, three numbers per line, correspond to the circus number, weight and height, respectively.
Output Description:
A positive integer m that represents the height of the Lohanta.
Input Example:
6
1 65 100
2 75 80
3 80 100
4 60 95
5 82 101
6 81 70
Output Example:
4
The code is as follows:
2, [programming problems] tie Golden Flower
Two Sohu programmers added one months class, finally a holiday, so they decided to spend a pleasant holiday with golden flower. Game rules: A total of 52 ordinary cards, the face of one of the 2,3,4,5,6,7,8,9,10,j,q,k,a, the size of the increase, each four, three cards per person. The two men compared to three cards in the hand size, big people win. The rules for the card type are as follows: 1. Three cards are the same as the Leopard 2. Three cards are connected to a straight (A23 not a straight) 3. There are only two cards. For a pair of leopards > CIS > Pairs > Ordinary cards in the same card type, compare the card type value (such as Aaa>kkk,qak >534,QQ2>10104) When there is no special card type for each person,
Input Description:
Enter two strings representing two player cards (e.g. "10KQ" "354"), first input as player 1, then input as Player 2
Output Description:
1 for Player 1 win 0 for draw-1 for player 2 win-2 for illegal input
Input Example:
KQ3 3q910qa 61025810 7kk632 74j10102 k77jkj 92668K 27A
Output Example:
11-1-111-1
The code is as follows:
#include <iostream> #include <vector> #include <algorithm>using namespace std;vector<int> Trans (string s) {vector<int> vec; for (int i= 0; i<s. Size (); i++) {if (s[i]== ' 1 ') {Vec. push_back (10);//1 and 0 are a whole i++; } if (s[i]== ' J ') Vec. Push_back (11); else if (s[i]== ' Q ') Vec. Push_back (12); else if (s[i]== ' K ') Vec. Push_back (13); else if (s[i]== ' A ') Vec. Push_back (14); else {int a= (int) (s[i]-' 0 '); Vec. Push_back (a); }} sort (VEC. Begin (), VEC. end ()); return VEC;} int Pmtype (Vector < int > Vec) {if (vec[0]==vec[1]&&vec[1]==vec[2]) {return 3; Leopard} if ((vec[0]+ 1 ==vec[1]) && (vec[1]+ 1 ==vec[2])) {return 2;//Shun Sub} if (vec[0 ]!=vec[1]&&vec[0]!=vec[2]&&vec[1]!=vec[2]) {return 0;//Normal card type is a single card } return 1; Pair}int Main () {string s1,s2; while (cin >>s1>>s2) {vector < int > vec1= trans (S1); Vector < int > vec2= trans (S2); int pmtype1= Pmtype (VEC1); int pmtype2= Pmtype (VEC2); if (pmtype1>pmtype2) {cout << 1 << endl; } if (pmtype1<pmtype2) {cout <<-1 << endl; } if (pmtype1== 3 &&pmtype2== 3) {if (vec1[0]>vec2[0]) {cout << 1 << Endl; } if (vec1[0]==vec2[0]) {//unreasonable cout << 2 << Endl; } else cout <<-1 << endl; } if (pmtype1== 2 && pmtype2== 2) {if (vec1[0]>vec2[0]) {cout << 1 << Endl ;} if (vec1[0]==vec2[0]) {cout << 0 << Endl;} else cout <<-1 << endl; } if (pmtype1== 1 &&pmtype2== 1) {int A, B; if (vec1[0]==vec1[1]) {a=vec1[0];} else {a=vec1[1];} if (vec2[0]==vec2[1]) {b=vec2[0];} else {b=vec2[1];} if (a==b) {int c,d; if (a==vec1[0]) {c=vec1[2]; } else c=vec1[0]; if (b==vec2[0]) {d=vec2[2]; } else d=vec2[0]; if (c>d) {cout << 1 << endl; } if (c<d) {cout <<-1 << endl; } else cout << 0 << Endl; } if (a>b) {cout << 1 << endl; } else {cout <<-1 << endl; }} if (pmtype1== 0 &&pmtype2== 0) {if (vec1[2]!=vec2[2 ] {if (vec1[2]>vec2[2]) {cout << 1 << endl; Continue; } else {cout <<-1 << endl; Continue; }} if (vec1[1]!=vec2[1]) {if (vec1[1]>vec2[1]) {cout << 1 << Endl; Continue; } else {cout <<-1 << endl; Continue; }} if (vec1[0]!=vec2[0]) {if (vec1[0]>vec2[0]) {cout << 1 << Endl; Continue; } if (vec1[0]<vec2[0]) {cout <<-1 << endl; Continue; }} cout << 0 << Endl; }} return 0;}
Running results: (http://www.anycodes.cn/zh/online programming website)
The answer is still wrong, to be improved!!
3. [Programming Questions] Bonus
Fox conducted a hackathon marathon, the company is divided into a total of n groups, each group of a room in a row to start the competition, after the end of the game did not publish results,
But each group can see its next two groups in the group of lower than their achievements, after the end of the game to send bonuses, in 1w units,
Each group will have at least 1w bonus, and if a group finds that its bonuses are not higher than those of its lower-grade group, it will not be satisfied,
Input Description:
Each set of data is entered N, and then n lines enter n positive integers, each representing the match score for each group.
Output Description:
The output of at least how many w bonuses are required
Input Example:
1020 32 12 32 45 11 21 31 41 33
Output Example:
20
The code is as follows:
#include <iostream> #include <algorithm> #include <vector>using namespace Std;int main () {int N; while (cin>>n) {vector<int> Chengji (N); for (int i=0;i<n;i++) cin>>chengji[i]; Vector<int> Money (n,1); Since each group can see itself in the next two groups in the group of lower than their results//from the back (forward), the first initialized to 1W, and then initialize the money value of I +1://1, when I corresponding to the results of i+1 lower, i+1 should take To more before, so there are money[i+1]=money[i]+1; 2, when I corresponding to the results and i+1 equal, anyway also see, will money[i+1] set to 1,//3, when I corresponding to the Grade I +1 high, money[i+1] should be at this time smaller, set it to 1, for this decline, you can use the reverse Loop Update//method for (int i=1;i<n;i++) {//forward if (Chengji[i]>chengji[i-1]) money[i]=money[ i-1]+1; else if (chengji[i]==chengji[i-1]) money[i]=money[i-1]; } for (int i=n-2;i>=0;i--) {//Reverse if (chengji[i]>chengji[i+1]) Money[i]=max (money[i],mo NEY[I+1]+1); } int result=0; for (int i=0;i<n;i++) result+=money[i]; Cout<<result<<endl; } return 0;}
Sohu 2016 Development Engineer programming problem