-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path631B.cpp
More file actions
71 lines (68 loc) · 1.53 KB
/
631B.cpp
File metadata and controls
71 lines (68 loc) · 1.53 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
#include <bits/stdc++.h>
using namespace std;
struct operate
{
int op1;
int op2;
string op3;
};
int main()
{
int n,m,k;
operate op;
int i;
vector<operate> oplist;
cin>>n>>m>>k;
int* row=new int[n+1]();
int* column=new int[m+1]();
string* matrix=new string[m*n];
for ( i=0;i<k;i++)
{
cin>>op.op1>>op.op2>>op.op3;
oplist.push_back(op);
}
for ( i = 0; i < k; ++i)
{
switch(oplist[i].op1)
{
case 1:
row[oplist[i].op2-1]++;break;
case 2:
column[oplist[i].op2-1]++;break;
}
}
for ( i = 0; i < k; ++i)
{
switch(oplist[i].op1)
{
case 1:
row[oplist[i].op2-1]--;
if (row[oplist[i].op2-1]==0)
{
for (int j = (oplist[i].op2-1)*m; j < oplist[i].op2*m; ++j)
{
matrix[j]=oplist[i].op3;
}
}
break;
case 2:
column[oplist[i].op2-1]--;
if (column[oplist[i].op2-1]==0)
{
for (int j = 0; j < n; ++j)
{
matrix[oplist[i].op2-1+j*m]=oplist[i].op3;
}
}
break;
}
}
for (int i = 0; i < m*n; ++i)
{
if (matrix[i]=="\0")matrix[i]="0";
cout<<matrix[i];
if (i%n!=m-1) cout<<" ";
else cout<<endl;
}
return 0;
}