{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n\u003cstyle type\u003d\"text/css\"\u003e\nh1,h2,h3,h4,h5,h6{margin-bottom:0;}\ndiv.textBG p{margin: 0 0 0.0001pt;}\n\u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003ccenter\u003e\n \u003ch1\u003e\u003cb\u003e\u003ci\u003e Connected Intersections \u003c/i\u003e\u003c/b\u003e\u003c/h1\u003e\n\u003c/center\u003e\n\u003cp\u003e\n In a certain urban area, you find a number of distinct locations designated by the\nletter N . These locations are interconnected by streets that can either allow one-\nway or two-way traffic. The city has embraced modern infrastructure, including some\nstreets equipped with tunnels and overpasses. Notably, it’s crucial to ensure seamless\ntravel between any pair of locations. Specifically, if you consider two locations, V and\nW , it must be feasible to travel both from V to W and from W to V.\n\u003c/p\u003e\n\u003cp\u003e\nYour assignment is to create a program that deciphers a description of the street\nnetwork within the city and determines whether the prerequisite of connectivity has\nbeen met.\n\u003c/p\u003e\n\u003ch4\u003e\u003cI\u003eInput\u003c/i\u003e\u003c/h4\u003e\n\u003cp\u003e\n The input contains several test cases. The first line of a test case contains two integers\nN and M , separated by a space, indicating the number of intersections (2 ≤ N ≤\n2000) and number of streets (2 ≤ M ≤ N (N − 1)/2). The next M lines describe the\ncity street system, with each line describing one street. A street description consists of\nthree integers V , W and P , separated by a blank space, where V and W are distinct\nidentifiers for intersections (1 ≤ V, W ≤ N, V !\u003d W ) and P can be 1 or 2; if P \u003d 1 the\nstreet is one-way, and traffic goes from V to W ; if P \u003d 2 then the street is two-way\nand links V and W . A pair of intersections is connected by at most one street. The\nlast test case is followed by a line that contains only two zero numbers separated by\na blank space.\n\u003c/p\u003e\n\u003ch4\u003e\u003cI\u003eOutput\u003c/i\u003e\u003c/h4\u003e\n\u003cp\u003e\n For each test case your program should print a single line containing an integer G,\nwhere G is equal to one if the condition of connectedness is satisfied, and G is zero\notherwise..\n\u003c/p\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 5\n1 2 1\n1 3 2\n2 4 1\n3 4 1\n4 1 2\n3 2\n1 2 2\n1 3 2\n3 2\n1 2 2\n1 3 1\n4 2\n1 2 2\n3 4 2\n0 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n1\n0\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}