Codevs 4159 Hzwer's mystery series

Source: Internet
Author: User

Title Description Description

Hzwer found a harmless series of mysteries ...

Now Hzwer want to do some work on this sequence, please answer the question of hzwer.

Operation One: Query the size of number I

Operation Two: Change the size of number I to X

Action Three: Reverses the entire sequence. That is, I put the number of the first n-i+1.

Enter a description Input Description

Input data The first row of two number n,m, indicating the sequence length and operand.

The second row n number, which represents the initial value of n elements.

The following m lines, beginning with a number OPR per line, indicate the type of operation.

Opr=1, followed by a number I, which indicates the size of the query number I.

Opr=2 is followed by two number i,x, which indicates that the number of I is changed to X.

A opr=3 that represents the sequence reversal.

Output description Output Description

For each query, output the answer.

Sample input Sample Input

4 6

1 3 2 4

1 3

2 2 6

3

2 1 3

1 3

1 1

Sample output Sample Output

2

6

3

Data range and Tips Data Size & Hint

For 20% data, 1<=n,m<=10.

For 40% data, 1<=n,m<=100.

For 60% data, 1<=n,m<=1000.

For 100% data, 1<=n,m<=100000,1<=a[i]<=100000.

Ideas:

Simulates whether the record is reversed.

Code:
#include <cstdio>using namespacestd;intn,m,a[100001];BOOLFlag;intMain () {inti,j,x,y,z; scanf ("%d%d",&n,&m);  for(i=1; i<=n;i++) scanf ("%d",&A[i]);  for(i=1; i<=m;i++) {scanf ("%d",&x); if(x==1) {scanf ("%d",&y); if(!flag) printf ("%d\n", A[y]); Elseprintf ("%d\n", a[n-y+1]); }        Else          if(x==2) {scanf ("%d%d",&y,&z); if(!flag) A[y]=Z; ElseA[n-y+1]=Z; }          ElseFlag=!Flag; }    return 0;}

Codevs 4159 Hzwer's mystery series

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.