fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. int n,m,h;
  9. cin>> m >> n >> h;
  10. vector<int> front(m);
  11. vector<int> left(n);
  12. int arr[m][n] = {0};
  13. for(int i = 0 ; i < n ; i++)
  14. {
  15. cin >> left[i];
  16. }
  17. for(int i = 0 ; i < m ; i++)
  18. {
  19. cin >> front[i];
  20. }
  21.  
  22. for(int k = 0 ; k < m ; k++)
  23. {
  24. for(int s = 0 ; s < n ; s++)
  25. {
  26. cin >> arr[k][s];
  27. }
  28. }
  29.  
  30. for(int i = 0 ; i < m ; i++)
  31. {
  32. for(int j = 0 ; j < n ; j++)
  33. {
  34. if(arr[i][j] == 0) continue;
  35. else
  36. {
  37. arr[i][j] = min(front[i],left[j]);
  38. }
  39. }
  40. }
  41.  
  42.  
  43.  
  44. for(int k = 0 ; k < m ; k++)
  45. {
  46. for(int s = 0 ; s < n ; s++)
  47. {
  48. cout<<arr[k][s]<<" ";
  49. }
  50. cout<<endl;
  51. }
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0s 15240KB
stdin
4 5 5
3 5 2 0 4
4 2 5 4
0 0 0 0 1
1 0 1 0 0
0 1 0 0 0
1 1 1 0 0
stdout
0 0 0 0 4 
2 0 2 0 0 
0 5 0 0 0 
3 4 2 0 0