Submit | All submissions | Best solutions | Back to list |
ACS - A concrete simulation |
You are given a matrix M of type 1234x5678. It is initially filled with integers 1...1234x5678 in row major order. Your task is to process a list of commands manipulating M. There are 4 types of commands:
- "R x y" swap the x-th and y-th row of M;
- "C x y" swap the x-th and y-th column of M;
- "Q x y" write out M(x,y);
- "W z" write out x and y where z=M(x,y).
Input
A list of valid commands. Input terminated by EOF.
Output
For each "Q x y" write out one line with the current value of M(x,y), for each "W z" write out one line with the value of x and y (interpreted as above) separated by a space.
Input: R 1 2 Q 1 1 Q 2 1 W 1 W 5679 C 1 2 Q 1 1 Q 2 1 W 1 W 5679 Output: 5679 1 2 1 1 1 5680 2 2 2 1 2
Added by: | czylabsonasa |
Date: | 2005-06-10 |
Time limit: | 7s |
Source limit: | 7777B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Folklore |
hide comments
|
||||||
2024-02-20 03:45:57
This is unexpectedly simple yet decent. |
||||||
2017-07-05 09:11:20
R,C,Q,W all in O(1) |
||||||
2016-07-01 20:20:44 deerishi
Good Adhoc Problem!! |
||||||
2016-06-09 16:11:09
Good Adhoc problem .. @Divyank Duvedi : It is r*5678 +c And a big thanks to Anurag for the corner case .. Ac in 0.00 s Hint : Can use ordered_map if using STL and it is blazing fast ............. instead of contiguous array and for every Query can be solved in O(1) with some extra memory .... :p Last edit: 2016-06-09 16:13:34 |
||||||
2016-03-06 13:11:53
amazing problm .....queries in O(1) |
||||||
2016-01-18 10:43:11 minhthai
nice problem :) big thank to the author |
||||||
2015-12-28 08:11:46 Diksha Jaiswal
AC in 0.0sec with all queries in O(1) |
||||||
2015-08-16 10:35:44 SangKuan
all in O(1) |
||||||
2015-08-02 13:28:21 (Tjandra Satria Gunawan)(曾毅昆)
Very good Ad hoc problem :) |
||||||
2015-07-03 21:10:53 chin
Easy One!!! |