fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool my_operation (bool a, bool b, bool* res) {
  5. if (!a and !b) return res[0];
  6. else if (!a and b) return res[1];
  7. else if (a and !b) return res[2];
  8. else return res[3];
  9. }
  10.  
  11. int main() {
  12. int w, h, n;
  13. bool truth_t[4];
  14. cin >> w >> h;
  15. n = w * h;
  16. bool *first_t = new bool [n];
  17. bool *second_t = new bool [n];
  18. char c;
  19. for (int i = 0; i < n; i++) {
  20. cin >> c;
  21. first_t[i] = (c == '1' ? true : false);
  22. }
  23. for (int i = 0; i < n; i++) {
  24. cin >> c;
  25. second_t[i] = (c == '1' ? true : false);
  26. }
  27. for (int i = 0; i < 4; i++) {
  28. cin >> c;
  29. truth_t[i] = (c == '1' ? true : false);
  30. }
  31. for (int i = 0; i < n; i++) {
  32. if (i != 0 && i % w == 0)
  33. cout << endl;
  34. cout << my_operation (first_t[i], second_t[i], truth_t);
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 15240KB
stdin
2 2
01
11
11
01
1111
stdout
11
11