fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4.  
  5.  
  6. int main() {
  7. int t; cin >> t;
  8. while(t--)
  9. {
  10. int n; cin >> n;
  11. ll x = 0, y = 0;
  12. cin.ignore();
  13. string s;
  14. getline(cin, s);
  15. stringstream ss(s);
  16. string tmp;
  17. while(ss >> tmp)
  18. {
  19. int len = tmp.size();
  20. for(int i = 0; i < len; i++)
  21. {
  22. if(tmp[i] == 'G')
  23. {
  24. y += 1;
  25. }
  26. else if(tmp[i] == 'L')
  27. {
  28. x -= 1;
  29. }
  30. else if(tmp[i] == 'R')
  31. {
  32. x += 1;
  33. }
  34. else if(tmp[i] == 'B')
  35. {
  36. y -= 1;
  37. }
  38. }
  39. }
  40. cout << x << ' ' << y << "\n";
  41. }
  42. /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  43. return 0;
  44. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty