-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path344B1.cpp
More file actions
76 lines (65 loc) · 1.46 KB
/
Copy path344B1.cpp
File metadata and controls
76 lines (65 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include<iostream>
#include<stdio.h>
using namespace std;
#define lli long long int
int arr[5100][5100];
pair<int,int> rw[5100];
pair<int,int> cl[5100];
void row(int r,int n,int val){
for(int i=0;i<n;i++){
arr[r][i] = val;
}
}
void col(int c,int n,int val){
for(int i=0;i<n;i++){
arr[i][c] = val;
}
}
void clr(int n ,int m){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(rw[i].second<cl[j].second){
arr[i][j] = cl[j].first;
}
else if(rw[i].second>cl[j].second){
arr[i][j] = rw[i].first;
}
//cout<<rw[i].second<<" "<<cl[j].second<<endl;
}
}
}
void clk(int n ,int m){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
arr[i][j] = 0;
}
}
}
void print(int n,int m){
for(int i=0;i<n;i++){
cout<<arr[i][0];
for(int j=1;j<m;j++){
cout<<" "<<arr[i][j];
}
cout<<endl;
}
}
int main(){
int n,m,k,a,b,c,r=0,ck=0;
while(cin>>n>>m>>k){
for(int i=0;i<k;i++){
cin>>a>>b>>c;
if(a==1){
rw[b-1].first = c;
rw[b-1].second = i+1;
}
else if(a==2){
cl[b-1].first = c;
cl[b-1].second = i+1;
}
}
clr(n,m);
print(n,m);
clk(n,m);
}
}