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 xth and yth row of M ;
"C x y" swap the xth and yth 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
hide comments
Anurag yadav:
20140211 17:13:58
try this


shashank:
20140123 20:24:10
Finally done .. after 4 WA's ..


BLANKRK:
20140120 09:49:44
NICE!!! 

cegprakash:
20131220 19:30:10
Nice problem! 

BACK:
20110920 22:35:35
is no of test case is greater than 1000000.


BACK:
20110920 22:35:35
my soln is correct but i m getting wa....help someone... 
Added by:  czylabsonasa 
Date:  20050610 
Time limit:  7s 
Source limit:  7777B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  Folklore 