玄关求调!!!QwQ
查看原帖
玄关求调!!!QwQ
752477
Dino_tang楼主2024/6/16 15:16
#include<bits/stdc++.h>
using namespace std;
const int N = 17;
string s[N];
int m,n;
int ans[N];								
int tmp[N];
vector<int>anss[1101];
int hhtt = 0;
bool check(vector<int> ans){
	memset(tmp,0,sizeof tmp);
	for(auto e:ans){
		for(int j = 0;j < m;j ++ ){
			if(s[e][j] == 'o'){
				tmp[j] ++;
			}
		}
	}
	for(int i = 0;i < m;i ++ ){
		if(tmp[i] == 0)return false;
	}
	return true;
}
void dfs(int pos,int k){
	if(k > pos){
		hhtt ++;
		for(int i = 1;i <= pos;i ++ ){
            anss[hhtt].push_back(ans[i]);
		}
		return;
	}
	for(int i = ans[k - 1] + 1;i <= n;i ++ ){
		ans[k] = i;
		dfs(pos,k + 1);
	}
}  
int main(){
	cin >> n >> m;
	for(int i = 1;i <= n;i ++ ){
		cin >> s[i];
	}
	for(int i = 1;i <= n;i ++ ){
		memset(tmp,0,sizeof tmp);
		dfs(i,1);
	}
	for(int i = 1;i <= hhtt;i ++ ){
		for(int j = 0;j < anss[i].size();j ++ ){
			cout << anss[i][j] << " ";
		}
		puts("");
	}
	for(int i = 1;i <= hhtt;i ++ ){
		if(check(anss[i])){
			cout << anss[i].size() << endl;
			break;
		}
	}
	return 0;
}    

在Atcoder上过了,但在Luogu上Wa了

2024/6/16 15:16
加载中...