abc069d <构造>

发布时间 2023-07-10 16:10:36作者: O2iginal

D - Grid Coloring

// https://atcoder.jp/contests/abc069/tasks/arc080_b
// <构造>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using LL = long long;
const int N = 110;
int g[N][N];

void solv()
{
    int h, w, n;
    cin >> h >> w >> n;
    int dir = 1, c = 1, r = 1;
    for (int i = 1, a; i <= n; i ++)
    {
        cin >> a;
        while (a --)
        {
            g[r][c] = i;

            c += dir;
            if (c > w)
            {
                c = w;
                dir = -1;
                r += 1;
            }
            else if (c < 1)
            {
                c = 1;
                dir = 1;
                r += 1;
            }
        }
    }
    for (int i = 1; i <= h; i ++)
    {
        for (int j = 1; j <= w; j ++) cout << g[i][j] << ' ';
        cout << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T = 1;
	// cin >> T;
    while (T --)
    {
        solv();
    }
    return 0;
}