这一题我想用vector,但是又WA又RE
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct paint {
ll color;//颜色
ll priority;//优先级
};
ll n, m, q;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int T;
cin >> T;
while (T--) {
vector<paint> row_vec(n + 1); // 使用vector来存储每行的绘画信息,初始化为n + 1个默认构造的paint结构体(其color和priority会初始化为0等默认值)
vector<paint> col_vec(m + 1);
cin >> n >> m >> q;
for (int i = 1; i <= q; i++) {
ll opt, x, c;
cin >> opt >> x >> c;
if (opt == 0) {
// 更新行信息
row_vec[x].color = c;
row_vec[x].priority = i;
}
else {
// 更新列信息
col_vec[x].color = c;
col_vec[x].priority = i;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (row_vec[i].priority > col_vec[j].priority) {
cout << row_vec[i].color;
}
else {
cout << col_vec[j].color;
}
}
printf("\n");
}
}
return 0;
}