forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
64 lines (54 loc) · 1.32 KB
/
B.cpp
File metadata and controls
64 lines (54 loc) · 1.32 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
#include <bits/stdc++.h>
using namespace std;
char a[555][555];
int main()
{
freopen("chip.in", "r", stdin);
freopen("chip.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
int m, n, h, x, ok = 1, row[555], col[555];
cin >> m >> n >> h;
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++)
a[i][j] = '*';
for (int i = 1; i <= m; i++)
cin >> row[i];
for (int i = 1; i <= n; i++)
cin >> col[i];
for (int i = 1; i <= m; i++)
{
int colNeed = n - row[i];
vector < pair<int,int> > cols;
for (int j = 1; j <= n; j++)
if (a[i][j] == '*' && col[j])
cols.push_back({-col[j], j});
else if (a[i][j] == '+' || a[i][j] == '|')
colNeed--;
sort(cols.begin(), cols.end());
if (cols.size() < colNeed)
{
ok = 0;
break;
}
for (int j = 0; j < colNeed; j++)
{
int c = cols[j].second;
col[c]--;
a[i][c] = a[i + h - 1][c] = '+';
for (int ii = i + 1; ii < i + h - 1; ii++)
a[ii][c] = '|';
}
}
for (int i = 1; i <= n; i++)
if (col[i])
ok = 0;
if (!ok) cout << "inconsistent" << endl;
else
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
cout << a[i][j];
cout << endl;
}
}