fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int t;
  8. cin >> t;
  9. if(t == 8 || t < 8)
  10. {
  11. return 0;
  12. }
  13. while (t--) {
  14. int p, q;
  15. string s;
  16. cin >> p >> q >> s;
  17.  
  18. if (p == 1 && s == "on") {
  19. if (q == 1) {
  20. cout << "on" << endl;
  21. } else {
  22. cout << "off" << endl;
  23. }
  24. } else if (p == 0 && s == "off") {
  25. if (q == 0) {
  26. cout << "off" << endl;
  27. } else {
  28. cout << "on" << endl;
  29. }
  30. } else {
  31. if (p == 0 && s == "on") {
  32. cout << (q == 0 ? "on" : "off") << endl;
  33. } else if (p == 1 && s == "off") {
  34. cout << (q == 1 ? "on" : "off") << endl;
  35. }
  36. }
  37. }
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5280KB
stdin
3
0 0 on
0 1 off
1 0 on
stdout
Standard output is empty