#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAXN = 205*205;
vector<int> g[MAXN];
bool vis[MAXN];
char mp[205][205];
int n, m, mt[MAXN];
int to_index(int i, int j) {
return i*(m+1)+j;
}
bool try_kuhn(int u) {
if (vis[u]) return false;
vis[u] = true;
for (int v : g[u]) {
if (mt[v] == -1 || try_kuhn(mt[v])) {
mt[v] = u;
return true;
}
}
return false;
}
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
mp[i][j] = '.';
char c; cin >> c;
if (c == '\\') {
int u = to_index(i-1, j-1), v = to_index(i, j);
g[u].emplace_back(v);
g[v].emplace_back(u);
} else if (c == '/') {
int u = to_index(i, j-1), v = to_index(i-1, j);
g[u].emplace_back(v);
g[v].emplace_back(u);
}
}
}
fill(mt, mt+MAXN, -1);
int ans = 0;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
if (!g[to_index(i, j)].empty()) {
fill(vis, vis+MAXN, false);
ans += try_kuhn(to_index(i, j));
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < m; j++) {
int x = to_index(i, j);
if (mt[x] != -1 && x >= mt[x]) {
if (x-mt[x] > m) mp[i][j] = '\\';
else mp[i][j+1] = '/';
}
}
}
cout << ans/2 << "\n";
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cout << mp[i][j];
}
cout << "\n";
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
base | 53/100 | ||||||
1 | Elfogadva | 0/0 | 4ms | 4240 KiB | |||
2 | Hibás válasz | 0/0 | 61ms | 6596 KiB | |||
3 | Elfogadva | 5/5 | 4ms | 4816 KiB | |||
4 | Részben helyes | 2/5 | 4ms | 5032 KiB | |||
5 | Részben helyes | 2/5 | 4ms | 5204 KiB | |||
6 | Elfogadva | 5/5 | 4ms | 5520 KiB | |||
7 | Részben helyes | 2/5 | 4ms | 5464 KiB | |||
8 | Részben helyes | 2/5 | 4ms | 5640 KiB | |||
9 | Részben helyes | 2/5 | 4ms | 5596 KiB | |||
10 | Részben helyes | 2/5 | 4ms | 5516 KiB | |||
11 | Részben helyes | 2/5 | 8ms | 5748 KiB | |||
12 | Részben helyes | 2/5 | 8ms | 5968 KiB | |||
13 | Részben helyes | 2/5 | 8ms | 6088 KiB | |||
14 | Részben helyes | 2/5 | 6ms | 6276 KiB | |||
15 | Részben helyes | 2/5 | 23ms | 6944 KiB | |||
16 | Elfogadva | 5/5 | 119ms | 8744 KiB | |||
17 | Elfogadva | 5/5 | 709ms | 9000 KiB | |||
18 | Időlimit túllépés | 0/5 | 857ms | 5092 KiB | |||
19 | Elfogadva | 5/5 | 50ms | 8044 KiB | |||
20 | Részben helyes | 2/5 | 71ms | 9156 KiB | |||
21 | Részben helyes | 2/5 | 70ms | 9180 KiB | |||
22 | Részben helyes | 2/5 | 621ms | 8572 KiB |