240232026-02-03 18:04:29algoproÚtépítéscpp17Time limit exceeded 95/100899ms2612 KiB
// UUID: 95dd9bc6-d067-45f9-9bf7-80bbfe9ad3f9
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> nbrs;
vector<int> mt;
vector<bool> vis;

bool kuhn(int Indx){
	if(vis[Indx]) return false;
	vis[Indx]=true;
	for(int x : nbrs[Indx]){
		if(mt[x]==-1 || kuhn(mt[x])){
			mt[x]=Indx;
			return true;
		}
	}
	return false;
}

int main() {
	int width, height;
	cin >> width >> height;
	int n=(width+1)*(height+1);
	nbrs.resize(n);
	for(int i=0;i<width;i++){
		string s; cin >> s;
		for(int j=0;j<height;j++){
			if(s[j]=='\\'){
				int u=i*(height+1)+j, v=(i+1)*(height+1)+(j+1);
				nbrs[u].push_back(v); nbrs[v].push_back(u);
			}
			if(s[j]=='/'){
				int u=(i+1)*(height+1)+j, v=i*(height+1)+(j+1);
				nbrs[u].push_back(v); nbrs[v].push_back(u);
			}
		}
	}
	mt.resize(n, -1);
	for(int i=0;i<n;i++){
		if((i/(height+1))%2==0){
			vis.assign(n, false);
			kuhn(i);
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++) cnt+=(-1!=mt[i]);
	cout << cnt;
	for(int i=0;i<width;i++){
		cout << '\n';
		for(int j=0;j<height;j++){
			int u=i*(height+1)+j;
			if(mt[u]==u+height+2 || u==mt[u+height+2]) cout << '\\';
			else if(mt[u+1]==u+height+1 || u+1==mt[u+height+1]) cout << '/';
			else cout << '.';
		}
	}
}
SubtaskSumTestVerdictTimeMemory
base95/100
1Accepted0/01ms316 KiB
2Accepted0/09ms2356 KiB
3Accepted5/51ms316 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms324 KiB
6Accepted5/51ms316 KiB
7Accepted5/51ms500 KiB
8Accepted5/51ms316 KiB
9Accepted5/51ms316 KiB
10Accepted5/51ms324 KiB
11Accepted5/52ms528 KiB
12Accepted5/51ms384 KiB
13Accepted5/52ms316 KiB
14Accepted5/52ms756 KiB
15Accepted5/54ms820 KiB
16Accepted5/527ms2152 KiB
17Accepted5/58ms2152 KiB
18Time limit exceeded0/5899ms2108 KiB
19Accepted5/517ms2100 KiB
20Accepted5/513ms2612 KiB
21Accepted5/512ms2580 KiB
22Accepted5/5717ms2368 KiB