1153B - Serval and Toy Bricks - CodeForces Solution


constructive algorithms greedy *1200

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define stream(line) istringstream in((line))
#define endl "\n"
#define F first
#define S second
#define clr(a, d) memset((a),d,sizeof(a))
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
const int M = 100 + 5;

void print_vector(vector<int> &v) {
    for (ll i = 0; i < v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}

ll dp[N][2];

int main() {
    fast
    int tc = 1;
    //cin >> tc;
    while (tc--) {
        int n,m, h;
        cin >> n >> m >> h;
        vector<int> r(n), c(m);
        for (int i = 0; i < m; ++i) {
            cin >> c[i];
        }
        for (int i = 0; i < n; ++i) {
            cin >> r[i];
        }
        int out[n+5][m+5];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                cin >> out[i][j];
            }
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if(out[i][j]){
                    cout << min(r[i], c[j]) << " ";
                }else{
                    cout << 0 << " ";
                }
            }
            cout << endl;
        }

    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

17A - Noldbach problem
1350A - Orac and Factors
1373A - Donut Shops
26A - Almost Prime
1656E - Equal Tree Sums
1656B - Subtract Operation
1656A - Good Pairs
1367A - Short Substrings
87A - Trains
664A - Complicated GCD
1635D - Infinite Set
1462A - Favorite Sequence
1445B - Elimination
1656C - Make Equal With Mod
567A - Lineland Mail
1553A - Digits Sum
1359B - New Theatre Square
766A - Mahmoud and Longest Uncommon Subsequence
701B - Cells Not Under Attack
702A - Maximum Increase
1656D - K-good
1426A - Floor Number
876A - Trip For Meal
1326B - Maximums
1635C - Differential Sorting
961A - Tetris
1635B - Avoid Local Maximums
20A - BerOS file system
1637A - Sorting Parts
509A - Maximum in Table