Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define MAXH 102
  4. #define MAXW 102
  5. #define MAXN 10005
  6. int h, w, n, a[MAXN], m[MAXH][MAXW];
  7. int main() {
  8. cin >> h >> w >> n;
  9. for(int i = 1; i <= n; ++i) {
  10. cin >> a[i];
  11. }
  12. int k = 1;
  13. for(int i = 0; i < h; ++i) {
  14. //cout << i << endl;
  15. if(i%2) {
  16. //cout<<"impar\n";
  17. for(int j = w - 1; j >= 0; --j) {
  18. if(a[k] == 0) {
  19. k++;
  20. }
  21. m[i][j] = k;
  22. a[k]--;
  23. }
  24. } else {
  25. for(int j = 0; j < w; ++j) {
  26. if(a[k] == 0) {
  27. k++;
  28. }
  29. m[i][j] = k;
  30. a[k]--;
  31. }
  32. }
  33. }
  34. for(int i = 0; i < h; ++i) {
  35. for(int j = 0; j < w; ++j) {
  36. cout << m[i][j] << ' ';
  37. }
  38. cout << "\n";
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement