5725-fun coloring

Source: Internet
Author: User

Http://livearchive.onlinejudge.org/index.php? Option = com_onlinejudge & Itemid = 8 & page = show_problem & problem = 3736

Problem solving: It is critical to understand the question ..

Because there are only two colors .. So binary enumeration... If a set has only one color (all is 0, or all is 1), false is returned. Otherwise, true is returned ..

Reading is painful .. The eggs are broken ..

Use stringstream.

Http://www.cppblog.com/Sandywin/archive/2007/07/13/27984.html

View code

# Include <iostream> # Include < String . H> # Include <Algorithm> # Include <Vector> # Include <Stdio. h># Include <Sstream> Using   Namespace  STD;  Int  N, m;  String  STR, ans;  Const   Int Maxn = 10000  ; Vector < Int > Node [maxn];  Int Check (Int  ID ){  Int Num = 0  ;  For ( Int I = 1 ; I <= m; I ++ ) {Num = 0  ;  For ( Int J = 0 ; J <node [I]. Size (); j ++)  If (ID &( 1 < Node [I] [J]) num ++ ;  If (Num = 0 | Num = node [I]. Size ()) Return   0  ;}  Return   1  ;}  Int  Main (){ Int  Test; scanf (  "  % D  " ,& Test );  While (Test -- ) {Scanf (  "  % D  " , & N ,& M); Getline (CIN, STR );  For ( Int I = 1 ; I <= m; I ++ ) Node [I]. Clear ();  For ( Int I = 1 ; I <= m; I ++ ) {Getline (CIN, STR); stringstream sin; sin < STR;  Int  A;  While (SIN> A) node [I]. push_back ( - 1 ); // Cout <A <Endl;  //  Cout <Endl;  }  Int Mm = 1 < N;  Int Flage = 0  ;  For ( Int I = 1 ; I <mm; I ++ ) If  (Check (I) {flage = 1 ; Break  ;}  If (Flage) ans + = '  Y  '  ;  Else Ans + = '  N  '  ; //  Getline (CIN, STR );  } Cout < Ans;  Return   0  ;} 

Contact Us

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.