Submission
Status:
---P-----P
Score: 20
User: gay69
Problemset: G.Peach's Backpack
Language: cpp
Time: 0.764 second
Submitted On: 2024-10-13 23:05:20
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plpll;
typedef pair<ll, plpll> plplpll;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll maxn = 5e5 + 5;
void mains() {
ll n, m, q;
cin >> m >> n >> q;
vector<ll> vec;
ll cur = 0;
char arr[n][m];
fill_n(arr[0], n * m, '.');
for (int i = 0; i < q; i++) {
ll x, y, k;
cin >> y >> x >> k;
k--;
bool flg = true;
if (k + y > m) {
break;
}
ll bottom = 0;
for (int i = 0; i < n; i++) {
ll cur = 0;
for (int j = k; j < min(m, k + y); j++) {
cur += (arr[i][j] == '.');
}
if (cur != y) {
break;
}
bottom++;
}
if (bottom < x) {
flg = false;
}
if (flg) {
for (int i = bottom - x; i < bottom; i++) {
for (int j = k; j < k + y; j++) {
arr[i][j] = cur++ + 'A';
cur %= 26;
}
}
continue;
}
cur += x * y;
cur %= 26;
vec.push_back(i + 1);
}
if (vec.empty()) {
cout << "NO ";
}
for (auto e : vec) {
cout << e + 1 << " ";
}
cout << "\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << arr[i][j];
}
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
// cin >> t;
while (t--) {
mains();
}
return 0;
}