Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define MAXH 102
- #define MAXW 102
- #define MAXN 10005
- int h, w, n, a[MAXN], m[MAXH][MAXW];
- int main() {
- cin >> h >> w >> n;
- for(int i = 1; i <= n; ++i) {
- cin >> a[i];
- }
- int k = 1;
- for(int i = 0; i < h; ++i) {
- //cout << i << endl;
- if(i%2) {
- //cout<<"impar\n";
- for(int j = w - 1; j >= 0; --j) {
- if(a[k] == 0) {
- k++;
- }
- m[i][j] = k;
- a[k]--;
- }
- } else {
- for(int j = 0; j < w; ++j) {
- if(a[k] == 0) {
- k++;
- }
- m[i][j] = k;
- a[k]--;
- }
- }
- }
- for(int i = 0; i < h; ++i) {
- for(int j = 0; j < w; ++j) {
- cout << m[i][j] << ' ';
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement