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