10.27 Noip Simulation Test (afternoon) (kneeling in the game 2333 less play)

Source: Internet
Author: User

"Problem description"

Zuma is a once-popular global game, the play is: in a track initially lined with a number of colored beads, any of the three adjacent beads will not be exactly the same color. After that, you can launch beads onto the track and join the original sequence. Once three or more beads of the same color become adjacent, they disappear immediately. Such elimination may occur in a chain, during which you will not be able to launch beads for the time being.

The developer is recently ready to write a playback tool for the player in the game process. They have completed the process recording function in the game, and the playback function is entrusted to you to complete the implementation.

The recording of the game process begins with the initial bead sequence on the track, followed by a series of actions that the player then makes. Your task is to calculate the new bead sequence in time after each operation.

"Input Format"

The first line is a string of uppercase ' a ' ~ ' Z ' that represents the initial bead sequence on the track, with different letters representing different colors.

The second line is a number, which indicates that the entire playback process has a common operation.

The next line corresponds to each operation in turn. Each operation consists of a number and an uppercase letter, separated by a space. Which,? For the color of the new beads. If there are beads before insertion, then ∈[0 ,?] indicates the order of the new beads in orbit after embedding (before elimination has occurred).

"Output Format"

Output a total line, given in turn each operation (and possibly immediately after the elimination phenomenon) on the track

page 2 total 6 pages

P74

sequence of beads.

If there are no beads on the track, the "-" is indicated.

"Sample Input"

ACCBA 5

1 B

0 A

2 B

4 C

0 A

"Sample Output"

Abccba

Aabccba

Aabbccba

-

A

"Sample Interpretation"

You think there's a temple in the mountains?

Game play less 23333 rules think wrong

WA becomes sb2333, and the wrong is not sticky. Big Ugly 2333

Code not finished 2333

"Problem description"

Stack is a powerful data structure, and its special function is to sort the array. For example, with a stack, the array 1,3,2 sequentially into the stack or out of the stack, which can be sorted from large to small:

1 into the stack, 3 into the stack, 3 out of the stack, 2 into the stack, 2 out of the stack, and 1 out of the stack.

in the above example, the stack sequence is 3,2,1, so the sorting of the array is implemented.

Unfortunately, there are times when only one stack can be used to completely sort an array. For example, given an array 2,1,3, with a stack, the maximum number of dictionary sequences that can be obtained is 3,1,2:

2 into the stack, 1 into the stack, 3 into the stack, 3 out of the stack, 1 out of the stack, and 2 out of the stack.

Please use a stack to sort a given array from large to small in the order of the stacks. When the order cannot be fully sorted, output a sequence of the largest dictionary-ordered stacks.

"Input Format"

Enter a total of 2 rows.

The first line contains an integer, which represents the length of the stack sequence.

The second line contains an integer that represents the stack sequence. The input data guarantees that the given sequence is a full 1 to n arrangement, i.e. no duplicate numbers appear.

"Output Format"

Only one row, a total of integers, represents the stack sequence you calculated.

"Sample Input"

3

2 1 3

"Sample Output"

3 1 2

"Sample Interpretation"

There is a tower in the mountain.

"Data size and conventions"

Simple greedy Idle write the St table suffix is good 23333

#include <cstdio>#defineMAXN 2000010using namespacestd;intn,a[maxn],s[maxn],top,now,f[maxn][ -],P[MAXN];intinit () {intx=0, f=1;Chars=GetChar ();  while(s<'0'|| S>'9'){if(s=='-') f=-1; s=GetChar ();}  while(s>='0'&&s<='9') {x=x*Ten+s-'0'; s=GetChar ();} returnx*F;}intMaxintXinty) {    returnX>y?x:y;}voidGet () { for(intI=1; i<=n;i++) f[i][0]=A[i];  for(intj=1; j<= -; j + +)         for(intI=1; i+ (1&LT;&LT;J)-1<=n;i++) F[i][j]=max (f[i][j-1],f[i+ (1<<j-1)][j-1]);  for(intI=1; i<=n;i++)         for(intj=0; j<= -; j + +)            if((1&LT;&LT;J) >i) {P[i]=j-1; Break; }}intQuery (intLintR) {    intk=p[r-l+1]; returnMax (f[l][k],f[r-(1&LT;&LT;K) +1][k]);}intMain () {Freopen ("haha.in","R", stdin); Freopen ("Haha.out","W", stdout); N=init ();  for(intI=1; i<=n;i++) A[i]=init (); now=N;    Get ();  for(intI=1; i<=n;i++) {s[++top]=A[i];  while(s[top]==now&&top) {printf ("%d", S[top]); Top--;now--; }         while(1){            intMx=query (i+1, N); if(mx<S[top]) {printf ("%d", S[top]); top--; }            Else  Break; }    }     while(top) {printf ("%d", S[top]); top--; }    return 0;}
View Code

"Problem description"

Little Q has a strong interest in computational geometry. He often stares at the plane Cartesian coordinate system and thinks about some interesting questions. Today, he thought of a very interesting topic:

first, the small Q will select each of the two axes on the positive half axis and the axis positive half axis. Then he connects the point of the axis to the point one by one of the axis, forming? Line segment and ensure that any two segments do not intersect. The small Q determines that there is only one type of connection. Finally, the small Q will give a query. For each query, you will

Given a point ? (? ? ,? ?) , please answer the line segment How many intersections will the OP and the line segments produce?

small Q found you are delving into the data structure, I hope you can help him solve the problem.

"Input Format"

Line 1th contains a positive integer, which represents the number of segments, and the 2nd row contains? a positive integer representing the small Q the horizontal axis of the points selected in the axes;

Line 3rd contains? a positive integer representing the small Q in ? The ordinate of the point selected by the axis; Line 4 contains a positive integer , which indicates the number of queries;

Subsequent lines, each line contains two positive integers? ? ,? ?, which represents the horizontal and vertical coordinates of the point given in the query.

"Output Format"

Together, each line contains a non-negative integer that represents your answer to the question.

"Sample Input"

3

4 5 3

3 5 4

2

1 1

3 3

"Sample Output"

0

3

"Sample Interpretation"

Then there's nothing in the tower.

Bare binary + math just judging

#include <cstdio>#include<cstring>#include<algorithm>#defineINF 1e9#defineMAXN 200010using namespacestd;intN,M,A[MAXN],B[MAXN];structnode{intx, y;} P[MAXN];intinit () {intx=0, f=1;Chars=GetChar ();  while(s<'0'|| S>'9'){if(s=='-') f=-1; s=GetChar ();}  while(s>='0'&&s<='9') {x=x*Ten+s-'0'; s=GetChar ();} returnx*F;}BOOLJudge (intIintXinty) {    DoubleY= (Double) p[i].y-(Double) x* (Double) p[i].y/(Double) p[i].x; returny<=y;}intMain () {Freopen ("hahaha.in","R", stdin); Freopen ("Hahaha.out","W", stdout); N=init ();  for(intI=1; i<=n;i++) A[i]=init ();  for(intI=1; i<=n;i++) B[i]=init (); Sort (a+1, A +1+n); sort (b +1, B +1+N);  for(intI=1; i<=n;i++) {p[i].x=a[i];p [i].y=B[i]; } N+ +;p [n].x=inf;p[n].y=inf; M=init ();intx, y;  while(m--) {x=init (); y=init (); intL=0, r=n,pos=0;  while(l<=R) {            intMid=l+r>>1; if(Judge (mid,x,y)) {L=mid+1;p os=Max (POS,MID); }            Elser=mid-1; } printf ("%d\n", POS); }    return 0;}
View Code

10.27 Noip Simulation Test (afternoon) (kneeling in the game 2333 less play)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.