# Codeforces 549B Looksery Party

Source: Internet
Author: User

Looksery Party

Solution:

Careful analysis will find that everyone will send a message to themselves this condition is very important!

This condition guarantees that there will be a solution, and the solution must start here.

When we get a sequence of guessing answers, assuming that the sequence is not 0, we don't need to invite anyone.

There is a 0 of the time to invite the answer is 0 people, and then to the person in its contact list of the answer to reduce one action, so that the operation may reduce some number to 0, but because everyone can contact themselves, it is necessary to lose all 0, so there must be a solution. Just keep a record of the people we choose.

`#include <bits/stdc++.h>using namespacestd;Const intN =109;d eque<int>Q;intA[n], g[n][n], use[n];intN;vector<int>ans;stringSt;intMain () {CIN>>N;  for(inti =1; I <= N; ++i) {cin>>St;  for(intj =0; J < N; ++j) {G[i][j+1] = (St[j] = ='1' ); }    }     for(inti =1; I <= N; ++i) {cin>>A[i]; if(A[i] = =0) Q.push_back (i); }     while( !Q.empty ()) {        intx =Q.front ();        Q.pop_front (); if(Use[x])Continue; USE[X]=1;        Ans.push_back (x);  for(inti =1; I <= N; i++ ) {            if(!use[i] &&G[x][i]) {                if(--a[i] = =0) Q.push_back (i); } }} cout<< ans.size () <<Endl;  for(int&I:ans) {cout<< I <<" "; }}`
View Code

Codeforces 549B Looksery Party

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.