mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-11-06 06:43:49 +00:00
feat: 添加P9117.cpp实现网格颜色更新功能
实现一个处理网格颜色更新的解决方案,根据输入操作更新行和列的颜色,并输出最终网格状态。支持多测试用例处理。
This commit is contained in:
parent
c96882f67e
commit
90fee25d70
48
src/10/27/P9117.cpp
Normal file
48
src/10/27/P9117.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
using ll = int64_t;
|
||||
|
||||
const ll maxn = 1e5+7;
|
||||
struct S{
|
||||
ll c,t;
|
||||
inline bool operator<(const S&other)const{
|
||||
return t<other.t;
|
||||
}
|
||||
}h[maxn],l[maxn];
|
||||
ll n,m,q;
|
||||
|
||||
static inline void solve(){
|
||||
std::cin>>n>>m>>q;
|
||||
for(ll i=1;i<=n;i++)h[i]={0,0};
|
||||
for(ll i=1;i<=m;i++)l[i]={0,0};
|
||||
for(ll i=1;i<=q;i++){
|
||||
ll opt,x,c;
|
||||
std::cin>>opt>>x>>c;
|
||||
if(opt==0){
|
||||
h[x]={c,i};
|
||||
}else{
|
||||
l[x]={c,i};
|
||||
}
|
||||
}
|
||||
for(ll i=1;i<=n;i++){
|
||||
for(ll j=1;j<=m;j++){
|
||||
if(h[i].c==0&&l[j].c==0){
|
||||
std::cout<<"0 ";
|
||||
continue;
|
||||
}
|
||||
std::cout<<std::max(h[i],l[j]).c<<" ";
|
||||
}
|
||||
std::cout<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main(){
|
||||
std::iostream::sync_with_stdio(false);
|
||||
std::cin.tie(nullptr);
|
||||
|
||||
ll T;
|
||||
std::cin>>T;
|
||||
while(T--)solve();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user