0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 17:56:28 +00:00

HDR003B. 「MCOI-06」Gerrymandering

https://hydro.ac/record/6156d32c2d8c78cdba6e733d
This commit is contained in:
Baoshuo Ren 2021-10-01 18:16:54 +08:00 committed by Baoshuo Ren
parent 096f23c71e
commit d7e56856e0
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

44
Hydro/HDR003B/HDR003B.cpp Normal file
View File

@ -0,0 +1,44 @@
#include <bits/stdc++.h>
using namespace std;
int t, n, m, k, c, l;
vector<int> ans;
int main() {
cin >> t;
while (t--) {
c = 1;
cin >> n >> m >> k;
if (n * m % k != 0) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
for (int i = 1; i <= n; i++) {
ans.clear();
if (i & 1) {
for (int j = 1; j <= m; j++) {
if (!--c) {
l++;
c = k;
}
ans.push_back(l);
}
} else {
for (int j = m; j >= 1; j--) {
if (!--c) {
l++;
c = k;
}
ans.insert(ans.begin(), l);
}
}
for (auto i : ans) {
cout << i << ' ';
}
cout << endl;
}
}
}
return 0;
}