Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Matrix Rotations

You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.


Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.


Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.

After the update, all the previous rotation operations have to be applied to the updated initial matrix.


Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.


Input


The first line contains a single integer N.

Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).

Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).

-1 will represent the end of input.


Output


For each Query operation print the element present at row index K and colum index L of the matrix in its current state.


Explanation


For Input:

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1


Initial Matrix

1 2

3 4


For R 90, clockwise rotation by 90 degrees, the matrix will become

3 1

4 2


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3.

For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1.


Again for R 90, clockwise rotation by 90 degrees, the matrix will become


4 3

2 1


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4.


For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,


6 2

3 4


After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).

After rotation the matrix will now become


4 3

2 6


Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6.


output

3

1

4

6


Sample Input 1

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1


Sample Output 1

3

1

4

6


Sample Input 2

2

5 6

7 8

R 90

Q 0 1

R 270

Q 1 1

R 180

U 0 0 4

Q 0 0

-1


Sample Output 2

5

8

8


i want exact sample outputs sir


Use a canvas of any reasonable size. Across the top of the canvas are 3 stationary lightbulbs (circles).

• If a lightbulb is currently turned on, it should be colored yellow. If it’s currently turned on, it should be colored black. When your program first starts, have 1 bulb on and the other 2 off.

• When the user clicks a lightbulb: Turn that lightbulb on (if it was off) or off (if it was on).

• The background color should depend on how many lightbulbs are currently turned on. If all of them are on, it should be white. If all of them are off, it should be black. If one of them is on, it should be dark grey. If two of them are on, it should be light grey


Code needed in processing format please


A queue is observed over 10000 one-second time intervals with data as given below in the array qdata.

Construct a Poisson nearest neighbour model with a single arrival and servicing pattern and hence answer the following questions:

  1. What is the average time taken for 1 customer to arrive?
  2. What is the average number of customer servicings per second?
  3. What is your estimate for the equilibrium probability 𝑃(𝑛≥4)
  4. P(n≥4), where 𝑛
  5. n is the queue size in this model?
  6. Suppose that two equivalent servers are introduced. What would the equilibrium probability 𝑃(𝑛≥4)
  7. P(n≥4) then be?
Given a MxN matrix,write a program to print all Anti-Diagonals elements of matrix

Input

The first line of input will contain a M, N values separated by space.
The second line will contain matrix A of dimensions MxN.

Output

The output should contain anti-diagonal elements separated by a line.
Explanation

For example, if M = 4, N = 4
Matrix A:




4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
So the output should be

1
2 5
3 6 9
4 7 10 13
8 11 14
12 15
16
Sample Input 1
2 3
1 5 5
2 7 8
Sample Output 1
1
5 2
5 7
8

Sample Input 2
3 4
1 2 3 4
5 6 7 8
9 10 11 12
Sample Output 2
1
2 5
3 6 9
4 7 10
8 11
12

Matrix Rotations

You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.


Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.


Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.

After the update, all the previous rotation operations have to be applied to the updated initial matrix.


Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.


Input


The first line contains a single integer N.

Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).

Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).

-1 will represent the end of input.


Output


For each Query operation print the element present at row index K and column index L of the matrix in its current state.


Right Triangle
Given a number N, write a program to print a triangular pattern of N lines with numbers as shown below.
Input

The input will be a single line containing a positive integer (N).
Output

The output should be N rows with numbers.
Note: There is no space between the numbers.
Explanation

For example, if the given number of rows is 4,
your code should print the following pattern
1
121
12321
1234321

Sample Input 1
4
Sample Output 1
1
121
12321
1234321

Sample Input 2
9
Sample Output 2
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321

Create a program the user will input 5 grades (choose any subjects and input any grades). Determine individual subjects either passed or failed. Lastly, calculate the average grade and determine whether if passed or failed.


Sample output:

Student Name: Victoria Jimenez


Filipino: 80 - Passed

Math: 74 - Failed

Science: 89 - Passed

English: 74 - Failed

PE: 90 - Passed


Hi Victoria Jimenez, Your Average Grade is 81.4 and you are PASSED!


*If the grade is failed the output should be


Hi Victoria Jimenez, Your Average Grade is 74.3 and you are FAILED!


Given a sentence S, write a program to print the frequency of each word in S. The output order should correspond with the word's input order of appearance.
Input

The input will be a single line containing a sentence S.
Output

The output contains multiple lines, with each line containing a word and its count separated by ": " with the order of appearance in the given sentence.
Explanation

For example, if the given sentence is "Hello world, welcome to python world", the output should be 
Hello: 1
world: 2
welcome: 1
to: 1
python: 1
Sample Input 1
Hello world welcome to python world
Sample Output 1
Hello: 1
world: 2
welcome: 1
to: 1
python: 1

Sample Input 2
This is my book
Sample Output 2
This: 1
is: 1
my: 1
book: 1

Tic-Tac-Toe game


Abhinav and Anjali are playing the Tic-Tac-Toe game. Tic-Tac-Toe is a game played on a grid that's three squares by three squares. Abhinav is O, and Anjali is X. Players take turns putting their marks in empty squares. The first player to get 3 of her marks in a diagonal or horizontal, or vertical row is the winner. When all nine squares are complete, the game is over. If no player has three marks in a row, the game ends in a tie. Write a program to decide the winner in the Tic-Tac-Toe game.


Input


The input will be three lines contain O's and X's separated by space.


Output


The output should be a single line containing either "Abhinav Wins" or "Anjali Wins" or "Tie".


Explanation


For example, if the input is

O X O
O X X
O O X 

as three of O's are in vertical row print "Abhinav Wins".



Sample Input 1

O X O

O X X

O O X


Sample Output 1

Abhinav Wins


Sample Input 2

O O X

X X O

X O O


Sample Output 2

Anjali Wins


i want exact sample outputs sir


Matrix Rotations

You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.


Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.


Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.

After the update, all the previous rotation operations have to be applied to the updated initial matrix.


Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.


Input


The first line contains a single integer N.

Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).

Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).

-1 will represent the end of input.


Output


For each Query operation print the element present at row index K and colum index L of the matrix in its current state.


Explanation


For Input:

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1


Initial Matrix

1 2

3 4


For R 90, clockwise rotation by 90 degrees, the matrix will become

3 1

4 2


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3.

For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1.


Again for R 90, clockwise rotation by 90 degrees, the matrix will become

4 3

2 1


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4.


For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,

6 2

3 4

After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).

After rotation the matrix will now become

4 3

2 6


Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6.

output

3

1

4

6

Sample Input 1

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1


Sample Output 1


3

1

4

6


Sample Input 2


2

5 6

7 8

R 90

Q 0 1

R 270

Q 1 1

R 180

U 0 0 4

Q 0 0

-1


Sample Output 2


5

8

8


i want exact sample outputs


LATEST TUTORIALS
APPROVED BY CLIENTS