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