Submission #4636968


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL H, W; cin >> H >> W;
	int N; cin >> N;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VVI ans(H, VI(W, 0));
	int idx = 0;
	FOR(i, 0, H) {
		if (i % 2 == 0) {
			FOR(j, 0, W) {
				if (a[idx])ans[i][j] = idx, a[idx]--;
				if (!a[idx])idx++;
			}
		}
		else {
			FORR(j, W - 1, 0 - 1) {
				if (a[idx])ans[i][j] = idx, a[idx]--;
				if (!a[idx])idx++;
			}
		}
	}
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			cout << ans[i][j] + 1 << " \n"[j == W - 1];
		}
	}

	return 0;
}

Submission Info

Submission Time
Task D - Grid Coloring
User Yang33
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1735 Byte
Status AC
Exec Time 2 ms
Memory 384 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KiB
0_01.txt AC 1 ms 256 KiB
0_02.txt AC 1 ms 256 KiB
1_00.txt AC 1 ms 256 KiB
1_01.txt AC 1 ms 256 KiB
1_02.txt AC 1 ms 256 KiB
1_03.txt AC 2 ms 384 KiB
1_04.txt AC 2 ms 384 KiB
1_05.txt AC 2 ms 384 KiB
1_06.txt AC 2 ms 384 KiB
1_07.txt AC 1 ms 256 KiB
1_08.txt AC 1 ms 256 KiB
1_09.txt AC 1 ms 256 KiB
1_10.txt AC 1 ms 256 KiB
1_11.txt AC 1 ms 256 KiB
1_12.txt AC 1 ms 256 KiB
1_13.txt AC 2 ms 384 KiB
1_14.txt AC 1 ms 256 KiB
1_15.txt AC 1 ms 256 KiB
1_16.txt AC 1 ms 256 KiB
1_17.txt AC 2 ms 256 KiB
1_18.txt AC 1 ms 256 KiB
1_19.txt AC 1 ms 256 KiB
1_20.txt AC 1 ms 256 KiB
1_21.txt AC 1 ms 256 KiB