【Henu ACM Round#18 D】Looksery Party

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

假设现在每个人收到的信息条数存在cnt里面 那个人猜的条数为target 则如果cnt[i]==target[i] 则我们就让第i个人来就好了。 因为s[i][i]=1恒成立。 所以第i个人它的cnt个数肯定递增了。 因此第i个人的cnt值和target值肯定再也不会相同了。 (其他人如果来的话,只会让这个人的cnt值越来越大,离target越来越远

所以如果对每个人都这么做的话。

最后肯定可以让所有人的cnt值都和target值不一样。

【代码】

#include <bits/stdc++.h>
using namespace std;

const int N = 100+10;

int n,cnt[N],target[N],bo[N+10];
char s[N][N];

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    for (int i = 1;i <= n;i++) cin >> (s[i]+1);
    for (int i = 1;i <= n;i++) cin >> target[i];
    while (1){
        int ok = 0;
        for (int i = 1;i <= n;i++)
            if (cnt[i]==target[i]){
                bo[i] = 1;
                for (int j = 1;j <= n;j++)
                {
                    int k = s[i][j]-'0';
                    cnt[j]+=k;
                }
                ok = 1;
            }
        if (!ok) break;
    }
    int num = 0;
    for (int i = 1;i <= n;i++) num+=bo[i];
    cout<<num<<endl;
    for (int i = 1;i <= n;i++)
        if (bo[i]){
            cout<<i<<' ';
        }
	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/8377532.html