Submission #1693946


Source Code Expand

//2017-10-19
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

#define N (100000+5)

vector<int> G[N];
bool col[N];
int ans;

#define v G[now][i]

void Dfs(int now, int F){
	For(i, 0, G[now].size()-1)
		if(v != F) Dfs(v, now);
	if(!col[now]) col[now] ^= 1, col[F] ^= 1, ++ans;
}

#undef v

int main(){
	int n, m, u, v;
	
	scanf("%d%d", &n, &m);
	For(i, 1, m){
		scanf("%d%d", &u, &v);
		G[u].pb(v); G[v].pb(u);
	}
	
	if(n == 1){
		puts("-1"); return 0;
	}

	Dfs(1, 0);

	if(col[0]) puts("-1");
	else printf("%d\n", ans);

	return 0;
}

Submission Info

Submission Time
Task F - Namori
User miaomiao
Language C++14 (GCC 5.4.1)
Score 0
Code Size 784 Byte
Status RE
Exec Time 2131 ms
Memory 268288 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:36:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
./Main.cpp:38:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &u, &v);
                        ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 1500 0 / 700
Status
AC × 2
RE × 2
AC × 6
WA × 14
AC × 6
WA × 14
TLE × 23
RE × 23
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
Subtask1 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt, 2_23.txt, 2_24.txt, 2_25.txt, 2_26.txt, 2_27.txt, 2_28.txt, 2_29.txt, 2_30.txt, 2_31.txt, 2_32.txt, 2_33.txt, 2_34.txt, 2_35.txt, 2_36.txt, 2_37.txt, 2_38.txt, 2_39.txt, 2_40.txt, 2_41.txt, 2_42.txt, 2_43.txt
Case Name Status Exec Time Memory
0_00.txt AC 3 ms 2560 KB
0_01.txt AC 3 ms 2560 KB
0_02.txt RE 259 ms 264704 KB
0_03.txt RE 261 ms 264704 KB
1_00.txt AC 3 ms 2560 KB
1_01.txt AC 46 ms 13312 KB
1_02.txt WA 37 ms 8192 KB
1_03.txt WA 31 ms 6264 KB
1_04.txt WA 45 ms 9472 KB
1_05.txt WA 47 ms 9088 KB
1_06.txt WA 43 ms 9088 KB
1_07.txt WA 45 ms 8192 KB
1_08.txt WA 43 ms 9600 KB
1_09.txt WA 37 ms 6144 KB
1_10.txt WA 38 ms 6016 KB
1_11.txt WA 39 ms 5888 KB
1_12.txt WA 40 ms 5888 KB
1_13.txt AC 42 ms 6528 KB
1_14.txt WA 41 ms 5888 KB
1_15.txt WA 41 ms 5888 KB
1_16.txt AC 40 ms 5888 KB
1_17.txt WA 40 ms 5888 KB
2_00.txt RE 255 ms 264704 KB
2_01.txt RE 440 ms 267904 KB
2_02.txt RE 469 ms 268160 KB
2_03.txt TLE 2105 ms 11512 KB
2_04.txt RE 500 ms 268032 KB
2_05.txt RE 522 ms 268032 KB
2_06.txt RE 533 ms 267904 KB
2_07.txt RE 500 ms 268032 KB
2_08.txt RE 533 ms 268032 KB
2_09.txt TLE 2104 ms 6400 KB
2_10.txt TLE 2104 ms 6144 KB
2_11.txt RE 1411 ms 268032 KB
2_12.txt TLE 2104 ms 6016 KB
2_13.txt RE 558 ms 267904 KB
2_14.txt TLE 2131 ms 267776 KB
2_15.txt TLE 2109 ms 46080 KB
2_16.txt TLE 2105 ms 9856 KB
2_17.txt RE 395 ms 268032 KB
2_18.txt RE 256 ms 264704 KB
2_19.txt RE 436 ms 268156 KB
2_20.txt TLE 2104 ms 11896 KB
2_21.txt RE 448 ms 267904 KB
2_22.txt RE 483 ms 268160 KB
2_23.txt RE 505 ms 268032 KB
2_24.txt RE 535 ms 267904 KB
2_25.txt RE 480 ms 268288 KB
2_26.txt RE 522 ms 268032 KB
2_27.txt TLE 2105 ms 15872 KB
2_28.txt RE 713 ms 268160 KB
2_29.txt TLE 2104 ms 6912 KB
2_30.txt TLE 2104 ms 6016 KB
2_31.txt RE 627 ms 268032 KB
2_32.txt TLE 2127 ms 214912 KB
2_33.txt TLE 2106 ms 27008 KB
2_34.txt TLE 2115 ms 89472 KB
2_35.txt TLE 2110 ms 52352 KB
2_36.txt TLE 2104 ms 7288 KB
2_37.txt TLE 2104 ms 8440 KB
2_38.txt TLE 2104 ms 8312 KB
2_39.txt TLE 2104 ms 7416 KB
2_40.txt TLE 2104 ms 7416 KB
2_41.txt TLE 2104 ms 7672 KB
2_42.txt TLE 2104 ms 7544 KB
2_43.txt TLE 2104 ms 7160 KB