From d81262baaeb41173a518072f978dada5ead89c13 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 9 Mar 2023 18:14:13 +0800 Subject: [PATCH] =?UTF-8?q?P9117=20[=E6=98=A5=E5=AD=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=202023]=20=E6=B6=82=E8=89=B2=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.luogu.com.cn/record/104148064 --- Luogu/P9117/P9117.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Luogu/P9117/P9117.cpp diff --git a/Luogu/P9117/P9117.cpp b/Luogu/P9117/P9117.cpp new file mode 100644 index 00000000..6a7e4d9d --- /dev/null +++ b/Luogu/P9117/P9117.cpp @@ -0,0 +1,54 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +void solve() { + int n, m, q; + + cin >> n >> m >> q; + + std::vector > 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; +}