CF453C.Little Pony and Summer Sun Celebration

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Twilight Sparkle learnt that the evil Nightmare Moon would return during the upcoming Summer Sun Celebration after one thousand years of imprisonment on the moon. She tried to warn her mentor Princess Celestia, but the princess ignored her and sent her to Ponyville to check on the preparations for the celebration.

Twilight Sparkle wanted to track the path of Nightmare Moon. Unfortunately, she didn't know the exact path. What she knew is the parity of the number of times that each place Nightmare Moon visited. Can you help Twilight Sparkle to restore any path that is consistent with this information?

Ponyville can be represented as an undirected graph (vertices are places, edges are roads between places) without self-loops and multi-edges. The path can start and end at any place (also it can be empty). Each place can be visited multiple times. The path must not visit more than 4n4n places.

输入格式

The first line contains two integers nn and mm ( 2<=n<=105; 0<=m<=1052<=n<=10^{5}; 0<=m<=10^{5} ) — the number of places and the number of roads in Ponyville. Each of the following mm lines contains two integers ui,viu_{i},v_{i} ( 1<=ui,vi<=n; uivi1<=u_{i},v_{i}<=n; u_{i}≠v_{i} ), these integers describe a road between places uiu_{i} and viv_{i} .

The next line contains nn integers: x1,x2,...,xnx_{1},x_{2},...,x_{n} (0<=xi<=1)(0<=x_{i}<=1) — the parity of the number of times that each place must be visited. If xi=0x_{i}=0 , then the ii -th place must be visited even number of times, else it must be visited odd number of times.

输出格式

Output the number of visited places kk in the first line ( 0<=k<=4n0<=k<=4n ). Then output kk integers — the numbers of places in the order of path. If xi=0x_{i}=0 , then the ii -th place must appear in the path even number of times, else ii -th place must appear in the path odd number of times. Note, that given road system has no self-loops, therefore any two neighbouring places in the path must be distinct.

If there is no required path, output -1. If there multiple possible paths, you can output any of them.

输入输出样例

  • 输入#1

    3 2
    1 2
    2 3
    1 1 1
    

    输出#1

    3
    1 2 3
    
  • 输入#2

    5 7
    1 2
    1 3
    1 4
    1 5
    3 4
    3 5
    4 5
    0 1 0 1 0
    

    输出#2

    10
    2 1 3 4 5 4 5 4 3 1 
  • 输入#3

    2 0
    0 0
    

    输出#3

    0
    
首页