fork download
  1. #include <bits/stdc++.h>
  2. #define tal2a ios::sync_with_stdio(false); cin.tie(nullptr);
  3. #define lolo long long
  4. const double PI = acos(-1.0);
  5. using namespace std;
  6. int main()
  7. {
  8. int x; cin >> x;
  9. string s; cin >> s;
  10. int cnt = 0;
  11. for (int i = 0; i <s.length(); i++) {
  12. if (s[i] == 'V') {
  13. cnt+=5;
  14. }
  15. else if (s[i] == 'W') {
  16. cnt+=2;
  17. }
  18. else if (s[i] == 'X'&&i+1<s.length()) {
  19. s.erase(i+1,1);
  20. }
  21. else if (s[i] == 'Y'&&i+1<s.length()) {
  22. s.push_back(s[i+1]);
  23. s.erase(i+1,1);
  24. }
  25. else if (s[i] == 'Z'&&i+1<s.length()) {
  26. if (s[i+1]=='V') {
  27. cnt/=5;
  28. s.erase(i+1,1);
  29. }
  30. else if (s[i+1]=='W'&&i+1<s.length()) {
  31. cnt/=2;
  32. s.erase(i+1,1);
  33. }
  34. }
  35. }
  36. cout << cnt;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty