0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 21:48:48 +00:00

P9117 [春季测试 2023] 涂色游戏

https://www.luogu.com.cn/record/104148064
This commit is contained in:
Baoshuo Ren 2023-03-09 18:14:13 +08:00
parent 7cd4ddfcee
commit d81262baae
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

54
Luogu/P9117/P9117.cpp Normal file
View File

@ -0,0 +1,54 @@
#include <iostream>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
void solve() {
int n, m, q;
cin >> n >> m >> q;
std::vector<std::pair<int, int> > g(n + 1), h(m + 1);
for (int i = 1, op, x, c; i <= q; i++) {
cin >> op >> x >> c;
if (op == 0) {
g[x] = std::make_pair(c, i);
} else { // op == 1
h[x] = std::make_pair(c, i);
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (g[i].second > h[j].second) {
cout << g[i].first;
} else {
cout << h[j].first;
}
if (j < m) {
cout << ' ';
} else { // j == m
cout << endl;
}
}
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) solve();
return 0;
}