{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eAlice and Bob are playing a game on a tree of n nodes. Each node is either black or white initially.\u003c/p\u003e\r\n\u003cp\u003eThey take turns to do the following operation:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eChoose a white node v from the current tree;\u003c/li\u003e\r\n\u003cli\u003eColor all white nodes on Path(1, v) to black.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eThe player who takes the last turn wins.\u003c/p\u003e\r\n\u003cp\u003eNow Alice takes the first turn. Help her\u0026nbsp;find out if she can win when they both use optimal strategy.\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line of input contains a integer n representing the number of nodes in the tree. 1\u0026lt;\u003dn\u0026lt;\u003d100000\u003c/p\u003e\r\n\u003cp\u003eThe second line contains n integers c1, c2 ,.. cn. 0\u0026lt;\u003dci\u0026lt;\u003d1.\u003cbr\u003eci\u003d0 means the ith node is white initially and ci\u003d1 means black.\u003c/p\u003e\r\n\u003cp\u003eNext n-1 lines describes n-1 edges in the tree. Each line contains two integers u and v, means there is a edge connecting u and v.\u0026nbsp;\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eIf Alice can\u0027t win print -1.\u003c/p\u003e\r\n\u003cp\u003eOtherwise determine all the nodes she can choose in the first turn in order to win. Print them in ascending order.\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e8\n1 1 0 1 0 0 1 0\n1 2\n1 3\n2 6\n3 4\n3 5\n5 7\n7 8\u0026nbsp;\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e20\n1 1 1 0 1 1 1 0 1 0 0 0 1 0 1 0 0 0 0 0\n1 2\n2 3\n2 4\n1 5\n1 6\n5 7\n5 8\n2 9\n8 10\n1 11\n1 12\n9 13\n6 14\n14 15\n7 16\n11 17\n2 18\n7 19\n12 20\u0026nbsp;\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\n11\n12\u0026nbsp;\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}