fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void tukar(int &a, int &b) {
  6. int temp = a;
  7. a = b;
  8. b = temp;
  9. }
  10.  
  11. int A[1001], B[1001];
  12.  
  13. int main() {
  14. int N, T, P, x, Q, y;
  15. cin >> N;
  16. // bola-bola di baris A
  17. for (int i = 0; i < N; i++) {
  18. cin >> A[i];
  19. }
  20. // bola-bola di baris B
  21. for (int i = 0; i < N; i++) {
  22. cin >> B[i];
  23. }
  24. cin >> T;
  25. while (T--) {
  26. cin >> P >> x >> Q >> y;
  27. if (P == 'A') {
  28. if (Q == 'A') {
  29. tukar(A[x-1], A[y-1]);
  30. }
  31. else {
  32. tukar(A[x-1], B[y-1]);
  33. }
  34. }
  35. else {
  36. if (Q == 'A') {
  37. tukar(B[x-1], A[y-1]);
  38. }
  39. else {
  40. tukar(B[x-1], B[y-1]);
  41. }
  42. }
  43. }
  44. }
Runtime error #stdin #stdout 0s 4432KB
stdin
2
1 2
2 1
1
A 2 B 2
stdout
Standard output is empty